<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>180842</bug_id>
          
          <creation_ts>2017-12-14 14:39:12 -0800</creation_ts>
          <short_desc>srflx and relay ICE candidates lack raddr (rel-addr) and rport (rel-port) attributes if getUserMedia access has not been granted</short_desc>
          <delta_ts>2017-12-14 18:16:09 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebRTC</component>
          <version>Safari 11</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mark Roberts">mroberts</reporter>
          <assigned_to name="youenn fablet">youennf</assigned_to>
          <cc>achristensen</cc>
    
    <cc>commit-queue</cc>
    
    <cc>eric.carlson</cc>
    
    <cc>jonlee</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1381837</commentid>
    <comment_count>0</comment_count>
    <who name="Mark Roberts">mroberts</who>
    <bug_when>2017-12-14 14:39:12 -0800</bug_when>
    <thetext>Reproduction Steps:

1. Create an RTCPeerConnection with STUN (and/or TURN) servers
2. Negotiate (doesn&apos;t matter if Safari offers or answers first)
3. Wait for ICE candidates

You can execute these steps using the following JSFiddle: https://jsfiddle.net/Lm7Lebz4/

Expected Result:

srflx and relay candidates include the raddr (rel-addr) and rport (rel-port) attributes required by RFC 5245, Section 15.1: https://tools.ietf.org/html/rfc5245#section-15.1

Actual Result:

srflx and relay candidates lack raddr and rport.

***

If you call `getUserMedia` before executing Steps 1–3 above, you will get a different result! raddr and rport will be present. These two cases are represented in the JSFiddle by the two buttons. Note: you may wish to simply copy the JavaScript from the JSFiddle, paste it into the browser console, and invoke `test(true)` or `test(false)` yourself, since calling `getUserMedia` first will trigger

&gt; NotAllowedError (DOM Exception 35): The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

when invoked from JSFiddle.

***

Other notes: I&apos;m investigating ICE failures between Safari and Firefox when Safari is not sharing any media. I&apos;m not sure if this is the cause of the failure or a symptom of some other issue. This issue also resembles this WebRTC Issue 1202: https://bugs.chromium.org/p/webrtc/issues/detail?id=1202</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1381841</commentid>
    <comment_count>1</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-12-14 14:46:34 -0800</bug_when>
    <thetext>Hi Mark, thanks for the report.
host candidates are filtered out for privacy reasons and so are raddr/rport information on reflexive and relay candidates.

I would be interested to know whether this causes any actual issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1381852</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Roberts">mroberts</who>
    <bug_when>2017-12-14 15:09:59 -0800</bug_when>
    <thetext>Hi Youenn,

Thanks for the quick response.

&gt; host candidates are filtered out for privacy reasons

Yes, this is what I expected. I think I remember you mentioning this at Kranky Geek. IMO, there should be no problem there.

&gt; and so are raddr/rport information on reflexive and relay candidates.

However, this seems to be the source of the interop problem with Firefox. If I write a little function to patch these up before sending them out:

  function patchIceCandidate(candidate) {
    var candidateStr = candidate.candidate;                                          
    var type = candidateStr.match(/typ ([^ ]*)/)[1];                                 
    switch (type) {                                                                  
      case &apos;srflx&apos;:                                                                  
      case &apos;prflx&apos;:                                                                  
      case &apos;relay&apos;:                                                                  
        var raddr = candidateStr.match(/raddr ([^ ]*)/);                             
        var rport = candidateStr.match(/rport ([^ ]*)/);                             
        if (!raddr || !rport) {                                                      
          console.warn(type + &apos; ICE candidate lacks raddr and/or rport: &apos; + candidateStr);
          if (!raddr) {                                                              
            candidateStr = candidateStr.replace(&apos;generation&apos;, &apos;raddr 0.0.0.0 generation&apos;);
          }                                                                          
          if (!rport) {                                                              
            candidateStr = candidateStr.replace(&apos;generation&apos;, &apos;rport 0 generation&apos;);
          }                                                                          
          candidate = new RTCIceCandidate({                                          
            candidate: candidateStr,                                                 
            sdpMid: candidate.sdpMid,                                                
            sdpMLineIndex: candidate.sdpMLineIndex                                   
          });                                                                        
        }                                                                            
      default:                                                                       
        break;                                                                       
    }
    return candidate;
  }

Then there are no more ICE failures in Firefox.

I can understand filtering the raddr and rport attributes if they include sensitive information; however, I suppose Firefox may be a bit stricter in its parsing of ICE candidates (since technically raddr and rport are required). Strangely, though, it doesn&apos;t raise an error. I will probably open an issue with them next.

Also, I can understand filtering the raddr and rport attributes if they includes sensitive information; however, in the test I shared, I see they are just set to 0.0.0.0 and 0 _if `getUserMedia` was previously called_ (note that it doesn&apos;t matter if the resulting MediaStreamTracks are added to any RTCPeerConnections or not). So maybe instead of filtering, Safari could use these dummy values?

Thanks!
Mark</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1381858</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Roberts">mroberts</who>
    <bug_when>2017-12-14 15:14:17 -0800</bug_when>
    <thetext>Here is an example error in Firefox&apos;s about:webrtc under &quot;Connection Log&quot; when such an ICE candidate is provided by Safari:

&gt; ICE(PC:1513292453729479 (id=2147483657 url=https://simpler-signaling.appspot.com/?iceTransportPolicy=relay)): Error parsing attribute: candidate:1735000762 1 udp 33562623 34.203.251.116 58685 typ relay generation 0 ufrag 4S1R network-cost 50</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1381869</commentid>
    <comment_count>4</comment_count>
      <attachid>329409</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-12-14 15:43:22 -0800</bug_when>
    <thetext>Created attachment 329409
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1381968</commentid>
    <comment_count>5</comment_count>
      <attachid>329409</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-12-14 18:14:08 -0800</bug_when>
    <thetext>Comment on attachment 329409
Patch

Clearing flags on attachment: 329409

Committed r225955: &lt;https://trac.webkit.org/changeset/225955&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1381969</commentid>
    <comment_count>6</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-12-14 18:14:10 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1381971</commentid>
    <comment_count>7</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-12-14 18:16:09 -0800</bug_when>
    <thetext>&lt;rdar://problem/36064667&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>329409</attachid>
            <date>2017-12-14 15:43:22 -0800</date>
            <delta_ts>2017-12-14 18:14:08 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-180842-20171214154322.patch</filename>
            <type>text/plain</type>
            <size>1785</size>
            <attacher name="youenn fablet">youennf</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjI1ODA5CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggYWU5ZGI0YmZjNjM5YTQz
NzBmYjFiN2I1NWZkNmQ5NDJmYTdkMDZiNi4uOGEwYzNkM2JhMjJmMWU1ZDE1NTU1MjU4MzQzYTU5
MTIzNmRjZjdlYyAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNv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aW9uQmFja2VuZC5jcHAgYi9Tb3VyY2UvV2Vi
Q29yZS9Nb2R1bGVzL21lZGlhc3RyZWFtL1BlZXJDb25uZWN0aW9uQmFja2VuZC5jcHAKaW5kZXgg
MmFkODRiZDk4MjU4ZjdjY2Y2ZTU5Y2U1YTIyNjJkNjFlYTUzMGU1OS4uNDY4N2UyMzI0NmY5YTc5
NjY3ZGM1ZWJhYjY0ODIwMTlkNGZkNzExOCAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvTW9k
dWxlcy9tZWRpYXN0cmVhbS9QZWVyQ29ubmVjdGlvbkJhY2tlbmQuY3BwCisrKyBiL1NvdXJjZS9X
ZWJDb3JlL01vZHVsZXMvbWVkaWFzdHJlYW0vUGVlckNvbm5lY3Rpb25CYWNrZW5kLmNwcApAQCAt
MzM2LDcgKzMzNiwxMyBAQCBzdGF0aWMgU3RyaW5nIGZpbHRlcklDRUNhbmRpZGF0ZShTdHJpbmcm
JiBzZHApCiAgICAgICAgICAgICBza2lwTmV4dEl0ZW0gPSBmYWxzZTsKICAgICAgICAgICAgIHJl
dHVybjsKICAgICAgICAgfQotICAgICAgICBpZiAoaXRlbSA9PSAicmFkZHIiIHx8IGl0ZW0gPT0g
InJwb3J0IikgeworICAgICAgICBpZiAoaXRlbSA9PSAicmFkZHIiKSB7CisgICAgICAgICAgICBm
aWx0ZXJlZFNEUC5hcHBlbmQoIiByYWRkciAwLjAuMC4wIik7CisgICAgICAgICAgICBza2lwTmV4
dEl0ZW0gPSB0cnVlOworICAgICAgICAgICAgcmV0dXJuOworICAgICAgICB9CisgICAgICAgIGlm
IChpdGVtID09ICJycG9ydCIpIHsKKyAgICAgICAgICAgIGZpbHRlcmVkU0RQLmFwcGVuZCgiIHJw
b3J0IDAiKTsKICAgICAgICAgICAgIHNraXBOZXh0SXRlbSA9IHRydWU7CiAgICAgICAgICAgICBy
ZXR1cm47CiAgICAgICAgIH0K
</data>

          </attachment>
      

    </bug>

</bugzilla>