From 2bc5797a5dfce4eca7636c11a02c85664d6ba400 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:02:43 +0000 Subject: [PATCH 01/11] unified: Copy unsafe WebView fetch query and tests unchanged Create a byte-for-byte baseline from original Swift for the unified Swift port, including query help and samples. Adaptations follow separately. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../security/CWE-079/UnsafeWebViewFetch.qhelp | 33 +++ .../security/CWE-079/UnsafeWebViewFetch.ql | 39 ++++ .../CWE-079/UnsafeWebViewFetchBad.swift | 6 + .../CWE-079/UnsafeWebViewFetchGood.swift | 6 + .../UnsafeWebViewFetch.expected | 156 +++++++++++++ .../UnsafeWebViewFetch.qlref | 2 + .../UnsafeWebViewFetch.swift | 217 ++++++++++++++++++ 7 files changed, 459 insertions(+) create mode 100644 unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelp create mode 100644 unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql create mode 100644 unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetchBad.swift create mode 100644 unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetchGood.swift create mode 100644 unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected create mode 100644 unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.qlref create mode 100644 unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelp b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelp new file mode 100644 index 000000000000..2efd5d35d5f3 --- /dev/null +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelp @@ -0,0 +1,33 @@ + + + + +

Fetching data in a web view without restricting the base URL may allow an attacker to access sensitive local data, for example using file://. Data can then be extracted from the software using the URL of a machine under the attacker's control. More generally, an attacker may use a URL under their control as part of a cross-site scripting attack.

+ +
+ + +

When loading HTML into a web view, always set the baseURL to an appropriate URL that you control, or to about:blank. Do not use nil, as this does not restrict URLs that can be resolved. Also do not use a baseURL that could itself be controlled by an attacker.

+ +
+ + +

In the following example, a call to UIWebView.loadHTMLString has the baseURL set to nil, which does not restrict URLs that can be resolved from within the web page.

+ + + +

To fix the problem, we set the baseURL to about:blank. This ensures that an attacker cannot resolve URLs that point to the local file system, or to web servers under their control.

+ + + +
+ + +
  • + iOS Bug Hunting - Web View XSS. +
  • + +
    +
    \ No newline at end of file diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql new file mode 100644 index 000000000000..3a2de3fa80ae --- /dev/null +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql @@ -0,0 +1,39 @@ +/** + * @name Unsafe WebView fetch + * @description Fetching data in a WebView without restricting the base URL may allow an attacker to access sensitive local data, or enable cross-site scripting attack. + * @kind path-problem + * @problem.severity warning + * @security-severity 7.8 + * @precision high + * @id swift/unsafe-webview-fetch + * @tags security + * external/cwe/cwe-079 + * external/cwe/cwe-095 + * external/cwe/cwe-749 + */ + +import swift +import codeql.swift.dataflow.DataFlow +import codeql.swift.security.UnsafeWebViewFetchQuery +import UnsafeWebViewFetchFlow::PathGraph + +from + UnsafeWebViewFetchFlow::PathNode sourceNode, UnsafeWebViewFetchFlow::PathNode sinkNode, + UnsafeWebViewFetchSink sink, string message +where + UnsafeWebViewFetchFlow::flowPath(sourceNode, sinkNode) and + sink = sinkNode.getNode() and + ( + // no base URL + not exists(sink.getBaseUrl()) and + message = "Tainted data is used in a WebView fetch." + or + // base URL is nil + sink.getBaseUrl() instanceof NilLiteralExpr and + message = "Tainted data is used in a WebView fetch without restricting the base URL." + or + // base URL is also tainted + UnsafeWebViewFetchFlow::flowToExpr(sink.getBaseUrl()) and + message = "Tainted data is used in a WebView fetch with a tainted base URL." + ) +select sink, sourceNode, sinkNode, message diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetchBad.swift b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetchBad.swift new file mode 100644 index 000000000000..f85adb1b267b --- /dev/null +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetchBad.swift @@ -0,0 +1,6 @@ + +let webview = UIWebView() + +... + +webview.loadHTMLString(htmlData, baseURL: nil) // BAD diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetchGood.swift b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetchGood.swift new file mode 100644 index 000000000000..5d89e5be672a --- /dev/null +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetchGood.swift @@ -0,0 +1,6 @@ + +let webview = UIWebView() + +... + +webview.loadHTMLString(htmlData, baseURL: URL(string: "about:blank")) // GOOD diff --git a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected new file mode 100644 index 000000000000..d796aa2da25e --- /dev/null +++ b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected @@ -0,0 +1,156 @@ +#select +| UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | UnsafeWebViewFetch.swift:103:30:103:84 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:106:25:106:25 | data | UnsafeWebViewFetch.swift:105:18:105:72 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:106:25:106:25 | data | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | UnsafeWebViewFetch.swift:109:30:109:53 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:120:25:120:39 | call to getRemoteData() | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:120:25:120:39 | call to getRemoteData() | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:121:25:121:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:121:25:121:25 | remoteString | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:124:25:124:51 | ... .+(_:_:) ... | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:124:25:124:51 | ... .+(_:_:) ... | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:127:25:127:25 | "..." | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:127:25:127:25 | "..." | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:139:25:139:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:139:25:139:25 | remoteString | Tainted data is used in a WebView fetch with a tainted base URL. | +| UnsafeWebViewFetch.swift:141:25:141:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:141:25:141:25 | remoteString | Tainted data is used in a WebView fetch with a tainted base URL. | +| UnsafeWebViewFetch.swift:154:15:154:15 | remoteData | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:154:15:154:15 | remoteData | Tainted data is used in a WebView fetch with a tainted base URL. | +| UnsafeWebViewFetch.swift:167:25:167:39 | call to getRemoteData() | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:167:25:167:39 | call to getRemoteData() | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:168:25:168:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:168:25:168:25 | remoteString | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:171:25:171:51 | ... .+(_:_:) ... | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:171:25:171:51 | ... .+(_:_:) ... | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:174:25:174:25 | "..." | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:174:25:174:25 | "..." | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:186:25:186:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:186:25:186:25 | remoteString | Tainted data is used in a WebView fetch with a tainted base URL. | +| UnsafeWebViewFetch.swift:188:25:188:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:188:25:188:25 | remoteString | Tainted data is used in a WebView fetch with a tainted base URL. | +| UnsafeWebViewFetch.swift:201:15:201:15 | remoteData | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:201:15:201:15 | remoteData | Tainted data is used in a WebView fetch with a tainted base URL. | +| UnsafeWebViewFetch.swift:210:25:210:25 | htmlData | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:210:25:210:25 | htmlData | Tainted data is used in a WebView fetch without restricting the base URL. | +edges +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | provenance | | +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:120:25:120:39 | call to getRemoteData() | provenance | | +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | provenance | | +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:167:25:167:39 | call to getRemoteData() | provenance | | +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:206:17:206:31 | call to getRemoteData() | provenance | | +| UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:94:10:94:37 | try ... | provenance | | +| UnsafeWebViewFetch.swift:103:30:103:84 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | provenance | | +| UnsafeWebViewFetch.swift:105:18:105:72 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:106:25:106:25 | data | provenance | | +| UnsafeWebViewFetch.swift:109:30:109:53 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | provenance | | +| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:121:25:121:25 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:124:25:124:51 | ... .+(_:_:) ... | provenance | | +| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:127:25:127:25 | "..." | provenance | | +| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:131:30:131:30 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:135:25:135:25 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:137:25:137:25 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:139:25:139:25 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:141:25:141:25 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:150:24:150:37 | .utf8 | provenance | | +| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:132:52:132:52 | remoteURL [some:0] | provenance | | +| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:138:47:138:47 | remoteURL [some:0] | provenance | | +| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:139:48:139:48 | remoteURL [some:0] | provenance | | +| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:153:85:153:85 | remoteURL [some:0] | provenance | | +| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:154:86:154:86 | remoteURL [some:0] | provenance | | +| UnsafeWebViewFetch.swift:131:30:131:30 | remoteString | UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | provenance | | +| UnsafeWebViewFetch.swift:132:19:132:61 | call to URL.init(string:relativeTo:) [some:0] | UnsafeWebViewFetch.swift:140:47:140:47 | remoteURL2 [some:0] | provenance | | +| UnsafeWebViewFetch.swift:132:19:132:61 | call to URL.init(string:relativeTo:) [some:0] | UnsafeWebViewFetch.swift:141:48:141:48 | remoteURL2 [some:0] | provenance | | +| UnsafeWebViewFetch.swift:132:52:132:52 | remoteURL [some:0] | UnsafeWebViewFetch.swift:132:19:132:61 | call to URL.init(string:relativeTo:) [some:0] | provenance | | +| UnsafeWebViewFetch.swift:138:47:138:47 | remoteURL [some:0] | UnsafeWebViewFetch.swift:138:47:138:56 | ...! | provenance | | +| UnsafeWebViewFetch.swift:139:48:139:48 | remoteURL [some:0] | UnsafeWebViewFetch.swift:139:48:139:57 | ...! | provenance | | +| UnsafeWebViewFetch.swift:140:47:140:47 | remoteURL2 [some:0] | UnsafeWebViewFetch.swift:140:47:140:57 | ...! | provenance | | +| UnsafeWebViewFetch.swift:141:48:141:48 | remoteURL2 [some:0] | UnsafeWebViewFetch.swift:141:48:141:58 | ...! | provenance | | +| UnsafeWebViewFetch.swift:150:19:150:41 | call to Data.init(_:) | UnsafeWebViewFetch.swift:152:15:152:15 | remoteData | provenance | | +| UnsafeWebViewFetch.swift:150:19:150:41 | call to Data.init(_:) | UnsafeWebViewFetch.swift:154:15:154:15 | remoteData | provenance | | +| UnsafeWebViewFetch.swift:150:24:150:37 | .utf8 | UnsafeWebViewFetch.swift:150:19:150:41 | call to Data.init(_:) | provenance | | +| UnsafeWebViewFetch.swift:153:85:153:85 | remoteURL [some:0] | UnsafeWebViewFetch.swift:153:85:153:94 | ...! | provenance | | +| UnsafeWebViewFetch.swift:154:86:154:86 | remoteURL [some:0] | UnsafeWebViewFetch.swift:154:86:154:95 | ...! | provenance | | +| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:168:25:168:25 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:171:25:171:51 | ... .+(_:_:) ... | provenance | | +| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:174:25:174:25 | "..." | provenance | | +| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:178:30:178:30 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:182:25:182:25 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:184:25:184:25 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:186:25:186:25 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:188:25:188:25 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:197:24:197:37 | .utf8 | provenance | | +| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:179:52:179:52 | remoteURL [some:0] | provenance | | +| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:185:47:185:47 | remoteURL [some:0] | provenance | | +| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:186:48:186:48 | remoteURL [some:0] | provenance | | +| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:200:90:200:90 | remoteURL [some:0] | provenance | | +| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:201:91:201:91 | remoteURL [some:0] | provenance | | +| UnsafeWebViewFetch.swift:178:30:178:30 | remoteString | UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | provenance | | +| UnsafeWebViewFetch.swift:179:19:179:61 | call to URL.init(string:relativeTo:) [some:0] | UnsafeWebViewFetch.swift:187:47:187:47 | remoteURL2 [some:0] | provenance | | +| UnsafeWebViewFetch.swift:179:19:179:61 | call to URL.init(string:relativeTo:) [some:0] | UnsafeWebViewFetch.swift:188:48:188:48 | remoteURL2 [some:0] | provenance | | +| UnsafeWebViewFetch.swift:179:52:179:52 | remoteURL [some:0] | UnsafeWebViewFetch.swift:179:19:179:61 | call to URL.init(string:relativeTo:) [some:0] | provenance | | +| UnsafeWebViewFetch.swift:185:47:185:47 | remoteURL [some:0] | UnsafeWebViewFetch.swift:185:47:185:56 | ...! | provenance | | +| UnsafeWebViewFetch.swift:186:48:186:48 | remoteURL [some:0] | UnsafeWebViewFetch.swift:186:48:186:57 | ...! | provenance | | +| UnsafeWebViewFetch.swift:187:47:187:47 | remoteURL2 [some:0] | UnsafeWebViewFetch.swift:187:47:187:57 | ...! | provenance | | +| UnsafeWebViewFetch.swift:188:48:188:48 | remoteURL2 [some:0] | UnsafeWebViewFetch.swift:188:48:188:58 | ...! | provenance | | +| UnsafeWebViewFetch.swift:197:19:197:41 | call to Data.init(_:) | UnsafeWebViewFetch.swift:199:15:199:15 | remoteData | provenance | | +| UnsafeWebViewFetch.swift:197:19:197:41 | call to Data.init(_:) | UnsafeWebViewFetch.swift:201:15:201:15 | remoteData | provenance | | +| UnsafeWebViewFetch.swift:197:24:197:37 | .utf8 | UnsafeWebViewFetch.swift:197:19:197:41 | call to Data.init(_:) | provenance | | +| UnsafeWebViewFetch.swift:200:90:200:90 | remoteURL [some:0] | UnsafeWebViewFetch.swift:200:90:200:99 | ...! | provenance | | +| UnsafeWebViewFetch.swift:201:91:201:91 | remoteURL [some:0] | UnsafeWebViewFetch.swift:201:91:201:100 | ...! | provenance | | +| UnsafeWebViewFetch.swift:206:17:206:31 | call to getRemoteData() | UnsafeWebViewFetch.swift:210:25:210:25 | htmlData | provenance | | +| UnsafeWebViewFetch.swift:206:17:206:31 | call to getRemoteData() | UnsafeWebViewFetch.swift:211:25:211:25 | htmlData | provenance | | +nodes +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | semmle.label | try ... | +| UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | semmle.label | call to String.init(contentsOf:) | +| UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | semmle.label | try! ... | +| UnsafeWebViewFetch.swift:103:30:103:84 | call to String.init(contentsOf:) | semmle.label | call to String.init(contentsOf:) | +| UnsafeWebViewFetch.swift:105:18:105:72 | call to String.init(contentsOf:) | semmle.label | call to String.init(contentsOf:) | +| UnsafeWebViewFetch.swift:106:25:106:25 | data | semmle.label | data | +| UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | semmle.label | try! ... | +| UnsafeWebViewFetch.swift:109:30:109:53 | call to String.init(contentsOf:) | semmle.label | call to String.init(contentsOf:) | +| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | semmle.label | call to getRemoteData() | +| UnsafeWebViewFetch.swift:120:25:120:39 | call to getRemoteData() | semmle.label | call to getRemoteData() | +| UnsafeWebViewFetch.swift:121:25:121:25 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:124:25:124:51 | ... .+(_:_:) ... | semmle.label | ... .+(_:_:) ... | +| UnsafeWebViewFetch.swift:127:25:127:25 | "..." | semmle.label | "..." | +| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | semmle.label | call to URL.init(string:) [some:0] | +| UnsafeWebViewFetch.swift:131:30:131:30 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:132:19:132:61 | call to URL.init(string:relativeTo:) [some:0] | semmle.label | call to URL.init(string:relativeTo:) [some:0] | +| UnsafeWebViewFetch.swift:132:52:132:52 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | +| UnsafeWebViewFetch.swift:135:25:135:25 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:137:25:137:25 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:138:47:138:47 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | +| UnsafeWebViewFetch.swift:138:47:138:56 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:139:25:139:25 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:139:48:139:48 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | +| UnsafeWebViewFetch.swift:139:48:139:57 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:140:47:140:47 | remoteURL2 [some:0] | semmle.label | remoteURL2 [some:0] | +| UnsafeWebViewFetch.swift:140:47:140:57 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:141:25:141:25 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:141:48:141:48 | remoteURL2 [some:0] | semmle.label | remoteURL2 [some:0] | +| UnsafeWebViewFetch.swift:141:48:141:58 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:150:19:150:41 | call to Data.init(_:) | semmle.label | call to Data.init(_:) | +| UnsafeWebViewFetch.swift:150:24:150:37 | .utf8 | semmle.label | .utf8 | +| UnsafeWebViewFetch.swift:152:15:152:15 | remoteData | semmle.label | remoteData | +| UnsafeWebViewFetch.swift:153:85:153:85 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | +| UnsafeWebViewFetch.swift:153:85:153:94 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:154:15:154:15 | remoteData | semmle.label | remoteData | +| UnsafeWebViewFetch.swift:154:86:154:86 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | +| UnsafeWebViewFetch.swift:154:86:154:95 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | semmle.label | call to getRemoteData() | +| UnsafeWebViewFetch.swift:167:25:167:39 | call to getRemoteData() | semmle.label | call to getRemoteData() | +| UnsafeWebViewFetch.swift:168:25:168:25 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:171:25:171:51 | ... .+(_:_:) ... | semmle.label | ... .+(_:_:) ... | +| UnsafeWebViewFetch.swift:174:25:174:25 | "..." | semmle.label | "..." | +| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | semmle.label | call to URL.init(string:) [some:0] | +| UnsafeWebViewFetch.swift:178:30:178:30 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:179:19:179:61 | call to URL.init(string:relativeTo:) [some:0] | semmle.label | call to URL.init(string:relativeTo:) [some:0] | +| UnsafeWebViewFetch.swift:179:52:179:52 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | +| UnsafeWebViewFetch.swift:182:25:182:25 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:184:25:184:25 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:185:47:185:47 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | +| UnsafeWebViewFetch.swift:185:47:185:56 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:186:25:186:25 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:186:48:186:48 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | +| UnsafeWebViewFetch.swift:186:48:186:57 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:187:47:187:47 | remoteURL2 [some:0] | semmle.label | remoteURL2 [some:0] | +| UnsafeWebViewFetch.swift:187:47:187:57 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:188:25:188:25 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:188:48:188:48 | remoteURL2 [some:0] | semmle.label | remoteURL2 [some:0] | +| UnsafeWebViewFetch.swift:188:48:188:58 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:197:19:197:41 | call to Data.init(_:) | semmle.label | call to Data.init(_:) | +| UnsafeWebViewFetch.swift:197:24:197:37 | .utf8 | semmle.label | .utf8 | +| UnsafeWebViewFetch.swift:199:15:199:15 | remoteData | semmle.label | remoteData | +| UnsafeWebViewFetch.swift:200:90:200:90 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | +| UnsafeWebViewFetch.swift:200:90:200:99 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:201:15:201:15 | remoteData | semmle.label | remoteData | +| UnsafeWebViewFetch.swift:201:91:201:91 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | +| UnsafeWebViewFetch.swift:201:91:201:100 | ...! | semmle.label | ...! | +| UnsafeWebViewFetch.swift:206:17:206:31 | call to getRemoteData() | semmle.label | call to getRemoteData() | +| UnsafeWebViewFetch.swift:210:25:210:25 | htmlData | semmle.label | htmlData | +| UnsafeWebViewFetch.swift:211:25:211:25 | htmlData | semmle.label | htmlData | +subpaths diff --git a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.qlref b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.qlref new file mode 100644 index 000000000000..18d2fc0a49df --- /dev/null +++ b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.qlref @@ -0,0 +1,2 @@ +query: queries/Security/CWE-079/UnsafeWebViewFetch.ql +postprocess: utils/test/InlineExpectationsTestQuery.ql diff --git a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift new file mode 100644 index 000000000000..cba21bcc4554 --- /dev/null +++ b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift @@ -0,0 +1,217 @@ + +// --- stubs --- + +class NSObject +{ +} + +struct URL +{ + init?(string: String) {} + init?(string: String, relativeTo: URL?) {} +} + +extension String { + init(contentsOf: URL) throws { + var data = "" + + // ... + + self.init(data) + } +} + +class NSURLRequest : NSObject +{ + enum CachePolicy : UInt + { + case useProtocolCachePolicy + } +} + +typealias TimeInterval = Double + +class URLRequest +{ + typealias CachePolicy = NSURLRequest.CachePolicy + + init(url: URL, cachePolicy: URLRequest.CachePolicy = .useProtocolCachePolicy, timeoutInterval: TimeInterval = 60.0) {} +} + +class Data +{ + init(_ elements: S) {} +} + +class WKNavigation : NSObject +{ +} + +class UIResponder : NSObject +{ +} + +class UIView : UIResponder +{ +} + +class UIWebView : UIView +{ + func loadRequest(_ request: URLRequest) {} // deprecated + + func load(_ data: Data, mimeType MIMEType: String, textEncodingName: String, baseURL: URL) {} // deprecated + + func loadHTMLString(_ string: String, baseURL: URL?) {} // deprecated +} + +class WKWebView : UIView +{ + func load(_ request: URLRequest) -> WKNavigation? { + // ... + + return WKNavigation() + } + + func load(_ data: Data, mimeType MIMEType: String, characterEncodingName: String, baseURL: URL) -> WKNavigation? { + // ... + + return WKNavigation() + } + + func loadHTMLString(_ string: String, baseURL: URL?) -> WKNavigation? { + // ... + + return WKNavigation() + } +} + +// --- tests --- + +func getRemoteData() -> String { + let url = URL(string: "http://example.com/") + do + { + return try String(contentsOf: url!) // $ Source + } catch { + return "" + } +} + +func testSimpleFlows() { + let webview = UIWebView() + + webview.loadHTMLString(try! String(contentsOf: URL(string: "http://example.com/")!), baseURL: nil) // $ Alert + + let data = try! String(contentsOf: URL(string: "http://example.com/")!) // $ Source + webview.loadHTMLString(data, baseURL: nil) // $ Alert + + let url = URL(string: "http://example.com/") + webview.loadHTMLString(try! String(contentsOf: url!), baseURL: nil) // $ Alert +} + +func testUIWebView() { + let webview = UIWebView() + + let localString = "

    Local HTML

    " + let localStringFragment = "

    Local HTML

    " + let remoteString = getRemoteData() + + webview.loadHTMLString(localString, baseURL: nil) // GOOD: the HTML data is local + webview.loadHTMLString(getRemoteData(), baseURL: nil) // $ Alert // BAD: HTML contains remote input, may access local secrets + webview.loadHTMLString(remoteString, baseURL: nil) // $ Alert + + webview.loadHTMLString("" + localStringFragment + "", baseURL: nil) // GOOD: the HTML data is local + webview.loadHTMLString("" + remoteString + "", baseURL: nil) // $ Alert + + webview.loadHTMLString("\(localStringFragment)", baseURL: nil) // GOOD: the HTML data is local + webview.loadHTMLString("\(remoteString)", baseURL: nil) // $ Alert + + let localSafeURL = URL(string: "about:blank") + let localURL = URL(string: "http://example.com/") + let remoteURL = URL(string: remoteString) + let remoteURL2 = URL(string: "/path", relativeTo: remoteURL) + + webview.loadHTMLString(localString, baseURL: localSafeURL!) // GOOD: a safe baseURL is specified + webview.loadHTMLString(remoteString, baseURL: localSafeURL!) // GOOD: a safe baseURL is specified + webview.loadHTMLString(localString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified + webview.loadHTMLString(remoteString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified + webview.loadHTMLString(localString, baseURL: remoteURL!) // GOOD: the HTML data is local + webview.loadHTMLString(remoteString, baseURL: remoteURL!) // $ Alert + webview.loadHTMLString(localString, baseURL: remoteURL2!) // GOOD: the HTML data is local + webview.loadHTMLString(remoteString, baseURL: remoteURL2!) // $ Alert + + let localRequest = URLRequest(url: localURL!) + let remoteRequest = URLRequest(url: remoteURL!) + + webview.loadRequest(localRequest) // GOOD: loadRequest is out of scope as it has no baseURL + webview.loadRequest(remoteRequest) // GOOD: loadRequest is out of scope as it has no baseURL + + let localData = Data(localString.utf8) + let remoteData = Data(remoteString.utf8) + webview.load(localData, mimeType: "text/html", textEncodingName: "utf-8", baseURL: localSafeURL!) // GOOD: the data is local + webview.load(remoteData, mimeType: "text/html", textEncodingName: "utf-8", baseURL: localSafeURL!) // GOOD: a safe baseURL is specified + webview.load(localData, mimeType: "text/html", textEncodingName: "utf-8", baseURL: remoteURL!) // GOOD: the HTML data is local + webview.load(remoteData, mimeType: "text/html", textEncodingName: "utf-8", baseURL: remoteURL!) // $ Alert +} + +func testWKWebView() { + let webview = WKWebView() + // note: `WKWebView` is safer than `UIWebView` as it has better security configuration options + // and is more locked down by default. + + let localString = "

    Local HTML

    " + let localStringFragment = "

    Local HTML

    " + let remoteString = getRemoteData() + + webview.loadHTMLString(localString, baseURL: nil) // GOOD: the HTML data is local + webview.loadHTMLString(getRemoteData(), baseURL: nil) // $ Alert + webview.loadHTMLString(remoteString, baseURL: nil) // $ Alert + + webview.loadHTMLString("" + localStringFragment + "", baseURL: nil) // GOOD: the HTML data is local + webview.loadHTMLString("" + remoteString + "", baseURL: nil) // $ Alert + + webview.loadHTMLString("\(localStringFragment)", baseURL: nil) // GOOD: the HTML data is local + webview.loadHTMLString("\(remoteString)", baseURL: nil) // $ Alert + + let localSafeURL = URL(string: "about:blank") + let localURL = URL(string: "http://example.com/") + let remoteURL = URL(string: remoteString) + let remoteURL2 = URL(string: "/path", relativeTo: remoteURL) + + webview.loadHTMLString(localString, baseURL: localSafeURL!) // GOOD: a safe baseURL is specified + webview.loadHTMLString(remoteString, baseURL: localSafeURL!) // GOOD: a safe baseURL is specified + webview.loadHTMLString(localString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified + webview.loadHTMLString(remoteString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified + webview.loadHTMLString(localString, baseURL: remoteURL!) // GOOD: the HTML data is local + webview.loadHTMLString(remoteString, baseURL: remoteURL!) // $ Alert + webview.loadHTMLString(localString, baseURL: remoteURL2!) // GOOD: the HTML data is local + webview.loadHTMLString(remoteString, baseURL: remoteURL2!) // $ Alert + + let localRequest = URLRequest(url: localURL!) + let remoteRequest = URLRequest(url: remoteURL!) + + webview.load(localRequest) // GOOD: loadRequest is out of scope as it has no baseURL + webview.load(remoteRequest) // GOOD: loadRequest is out of scope as it has no baseURL + + let localData = Data(localString.utf8) + let remoteData = Data(remoteString.utf8) + webview.load(localData, mimeType: "text/html", characterEncodingName: "utf-8", baseURL: localSafeURL!) // GOOD: the data is local + webview.load(remoteData, mimeType: "text/html", characterEncodingName: "utf-8", baseURL: localSafeURL!) // GOOD: a safe baseURL is specified + webview.load(localData, mimeType: "text/html", characterEncodingName: "utf-8", baseURL: remoteURL!) // GOOD: the HTML data is local + webview.load(remoteData, mimeType: "text/html", characterEncodingName: "utf-8", baseURL: remoteURL!) // $ Alert +} + +func testQHelpExamples() { + let webview = UIWebView() + let htmlData = getRemoteData() + + // ... + + webview.loadHTMLString(htmlData, baseURL: nil) // $ Alert + webview.loadHTMLString(htmlData, baseURL: URL(string: "about:blank")) // GOOD +} + +testSimpleFlows() +testUIWebView() +testWKWebView() +testQHelpExamples() From 2e1536ec953481d8760dd95bea2bd661e8677fe1 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:04:50 +0000 Subject: [PATCH 02/11] unified: Collect original unsafe WebView fetch logic in query Copy the data flow configuration and query-specific models from the original Swift libraries without API or behavior adaptations. Keep source paths for provenance; the compiling port follows separately. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../security/CWE-079/UnsafeWebViewFetch.ql | 127 +++++++++++++++++- 1 file changed, 126 insertions(+), 1 deletion(-) diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql index 3a2de3fa80ae..3a75e3467776 100644 --- a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql @@ -14,7 +14,132 @@ import swift import codeql.swift.dataflow.DataFlow -import codeql.swift.security.UnsafeWebViewFetchQuery +import codeql.swift.dataflow.TaintTracking +import codeql.swift.dataflow.FlowSources +private import codeql.swift.dataflow.ExternalFlow + +// From swift/ql/lib/codeql/swift/security/UnsafeWebViewFetchQuery.qll: + +/** + * Provides a taint-tracking configuration for reasoning about unsafe + * webview fetch vulnerabilities. + */ + +/** + * A taint configuration from taint sources to sinks (and `baseURL` arguments) + * for this query. + */ +module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { + predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource } + + predicate isSink(DataFlow::Node node) { + exists(UnsafeWebViewFetchSink sink | + node = sink or + node.asExpr() = sink.getBaseUrl() + ) + } + + predicate isBarrier(DataFlow::Node barrier) { barrier instanceof UnsafeWebViewFetchBarrier } + + predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { + any(UnsafeWebViewFetchAdditionalFlowStep s).step(nodeFrom, nodeTo) + } + + predicate observeDiffInformedIncrementalMode() { + none() // can't override location accurately because of secondary use in select. + } +} + +/** + * Detect taint flow of taint sources to sinks (and `baseURL` arguments) for this query. + */ +module UnsafeWebViewFetchFlow = TaintTracking::Global; + +// From swift/ql/lib/codeql/swift/security/UnsafeWebViewFetchExtensions.qll: + +/** + * Provides classes and predicates for reasoning about unsafe + * webview fetch vulnerabilities. + */ + +/** + * A dataflow sink for unsafe webview fetch vulnerabilities. + */ +abstract class UnsafeWebViewFetchSink extends DataFlow::Node { + /** + * Gets the `baseURL` argument associated with this sink (if any). These arguments affect + * the way sinks are reported and are also sinks themselves. + */ + Expr getBaseUrl() { none() } +} + +/** + * A barrier for unsafe webview fetch vulnerabilities. + */ +abstract class UnsafeWebViewFetchBarrier extends DataFlow::Node { } + +/** + * A unit class for adding additional flow steps. + */ +class UnsafeWebViewFetchAdditionalFlowStep extends Unit { + /** + * Holds if the step from `node1` to `node2` should be considered a flow + * step for paths related to unsafe webview fetch vulnerabilities. + */ + abstract predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo); +} + +/** + * A default uncontrolled format string sink, such as certain arguments + * to `UIWebView.loadHTMLString`. + */ +private class UIKitWebKitWebViewFetchSink extends UnsafeWebViewFetchSink { + Expr baseUrl; + + UIKitWebKitWebViewFetchSink() { + exists(Method funcDecl, CallExpr call, string className, string funcName, int arg, int baseArg | + // arguments to method calls... + ( + // `loadHTMLString` + className = ["UIWebView", "WKWebView"] and + funcName = "loadHTMLString(_:baseURL:)" and + arg = 0 and + baseArg = 1 + or + // `UIWebView.load` + className = "UIWebView" and + funcName = "load(_:mimeType:textEncodingName:baseURL:)" and + arg = 0 and + baseArg = 3 + or + // `WKWebView.load` + className = "WKWebView" and + funcName = "load(_:mimeType:characterEncodingName:baseURL:)" and + arg = 0 and + baseArg = 3 + ) and + call.getStaticTarget() = funcDecl and + // match up `className`, `funcName`. + funcDecl.hasQualifiedName(className, funcName) and + // match up `this`, `baseURL` + this.asExpr() = call.getArgument(arg).getExpr() and // URL + baseUrl = call.getArgument(baseArg).getExpr() // baseURL + ) + } + + override Expr getBaseUrl() { result = baseUrl } +} + +/** + * A sink defined in a CSV model. + * + * Note that sinks defined in this way never have a recognized `baseURL` + * argument, which may limit the accuracy of results. + */ +private class DefaultUnsafeWebViewFetchSink extends UnsafeWebViewFetchSink { + DefaultUnsafeWebViewFetchSink() { sinkNode(this, "webview-fetch") } +} + import UnsafeWebViewFetchFlow::PathGraph from From 7c3b4e0cd7c80895be9ee03c1a943793fe5a8a5a Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:30:19 +0000 Subject: [PATCH 03/11] unified: Port unsafe WebView fetch with a compiling test baseline Use unified taint tracking and declarative UIWebView/WKWebView sink models. Preserve checks for nil, absent, and tainted base URLs, and point the inline-expectation test at the unified query. The focused test passes with 12 result rows and no inline expectation failures. Retain six tainted-base-URL cases as MISSING for follow-up; this commit does not repair shared data flow or extraction. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- unified/ql/lib/ext/webview.model.json | 17 ++ .../security/CWE-079/UnsafeWebViewFetch.ql | 119 +------- .../UnsafeWebViewFetch.expected | 268 ++++++++---------- .../UnsafeWebViewFetch.qlref | 5 +- .../UnsafeWebViewFetch.swift | 12 +- 5 files changed, 160 insertions(+), 261 deletions(-) create mode 100644 unified/ql/lib/ext/webview.model.json diff --git a/unified/ql/lib/ext/webview.model.json b/unified/ql/lib/ext/webview.model.json new file mode 100644 index 000000000000..b95bccbf55d1 --- /dev/null +++ b/unified/ql/lib/ext/webview.model.json @@ -0,0 +1,17 @@ +{ + "extensions": [ + { + "addsTo": { + "pack": "codeql/unified-all", + "extensible": "legacySinkModel" + }, + "data": [ + // namespace, type, subtypes, name, signature, ext, input, kind, provenance + ["", "UIWebView", true, "loadHTMLString(_:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"], + ["", "WKWebView", true, "loadHTMLString(_:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"], + ["", "UIWebView", true, "load(_:mimeType:textEncodingName:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"], + ["", "WKWebView", true, "load(_:mimeType:characterEncodingName:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"] + ] + } + ] +} diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql index 3a75e3467776..ff774f0349d4 100644 --- a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql @@ -5,32 +5,33 @@ * @problem.severity warning * @security-severity 7.8 * @precision high - * @id swift/unsafe-webview-fetch + * @id unified/swift/unsafe-webview-fetch * @tags security * external/cwe/cwe-079 * external/cwe/cwe-095 * external/cwe/cwe-749 */ -import swift -import codeql.swift.dataflow.DataFlow -import codeql.swift.dataflow.TaintTracking -import codeql.swift.dataflow.FlowSources -private import codeql.swift.dataflow.ExternalFlow +import unified -// From swift/ql/lib/codeql/swift/security/UnsafeWebViewFetchQuery.qll: +/** A modeled WebView fetch, with its associated base URL if present. */ +private class UnsafeWebViewFetchSink extends DataFlow::Node { + UnsafeWebViewFetchSink() { Models::isSink(this, "webview-fetch") } -/** - * Provides a taint-tracking configuration for reasoning about unsafe - * webview fetch vulnerabilities. - */ + Expr getBaseUrl() { + exists(CallExpr call | + this.asExpr() = call.getAnArgument().getValue() and + result = call.getNamedArgument("baseURL") + ) + } +} /** * A taint configuration from taint sources to sinks (and `baseURL` arguments) * for this query. */ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { - predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource } + predicate isSource(DataFlow::Node node) { Models::isSource(node, _) } predicate isSink(DataFlow::Node node) { exists(UnsafeWebViewFetchSink sink | @@ -39,12 +40,6 @@ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { ) } - predicate isBarrier(DataFlow::Node barrier) { barrier instanceof UnsafeWebViewFetchBarrier } - - predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { - any(UnsafeWebViewFetchAdditionalFlowStep s).step(nodeFrom, nodeTo) - } - predicate observeDiffInformedIncrementalMode() { none() // can't override location accurately because of secondary use in select. } @@ -52,94 +47,10 @@ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { /** * Detect taint flow of taint sources to sinks (and `baseURL` arguments) for this query. + * TODO: Recover the tainted-base-URL paths marked MISSING in the tests. */ module UnsafeWebViewFetchFlow = TaintTracking::Global; -// From swift/ql/lib/codeql/swift/security/UnsafeWebViewFetchExtensions.qll: - -/** - * Provides classes and predicates for reasoning about unsafe - * webview fetch vulnerabilities. - */ - -/** - * A dataflow sink for unsafe webview fetch vulnerabilities. - */ -abstract class UnsafeWebViewFetchSink extends DataFlow::Node { - /** - * Gets the `baseURL` argument associated with this sink (if any). These arguments affect - * the way sinks are reported and are also sinks themselves. - */ - Expr getBaseUrl() { none() } -} - -/** - * A barrier for unsafe webview fetch vulnerabilities. - */ -abstract class UnsafeWebViewFetchBarrier extends DataFlow::Node { } - -/** - * A unit class for adding additional flow steps. - */ -class UnsafeWebViewFetchAdditionalFlowStep extends Unit { - /** - * Holds if the step from `node1` to `node2` should be considered a flow - * step for paths related to unsafe webview fetch vulnerabilities. - */ - abstract predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo); -} - -/** - * A default uncontrolled format string sink, such as certain arguments - * to `UIWebView.loadHTMLString`. - */ -private class UIKitWebKitWebViewFetchSink extends UnsafeWebViewFetchSink { - Expr baseUrl; - - UIKitWebKitWebViewFetchSink() { - exists(Method funcDecl, CallExpr call, string className, string funcName, int arg, int baseArg | - // arguments to method calls... - ( - // `loadHTMLString` - className = ["UIWebView", "WKWebView"] and - funcName = "loadHTMLString(_:baseURL:)" and - arg = 0 and - baseArg = 1 - or - // `UIWebView.load` - className = "UIWebView" and - funcName = "load(_:mimeType:textEncodingName:baseURL:)" and - arg = 0 and - baseArg = 3 - or - // `WKWebView.load` - className = "WKWebView" and - funcName = "load(_:mimeType:characterEncodingName:baseURL:)" and - arg = 0 and - baseArg = 3 - ) and - call.getStaticTarget() = funcDecl and - // match up `className`, `funcName`. - funcDecl.hasQualifiedName(className, funcName) and - // match up `this`, `baseURL` - this.asExpr() = call.getArgument(arg).getExpr() and // URL - baseUrl = call.getArgument(baseArg).getExpr() // baseURL - ) - } - - override Expr getBaseUrl() { result = baseUrl } -} - -/** - * A sink defined in a CSV model. - * - * Note that sinks defined in this way never have a recognized `baseURL` - * argument, which may limit the accuracy of results. - */ -private class DefaultUnsafeWebViewFetchSink extends UnsafeWebViewFetchSink { - DefaultUnsafeWebViewFetchSink() { sinkNode(this, "webview-fetch") } -} - import UnsafeWebViewFetchFlow::PathGraph from @@ -154,7 +65,7 @@ where message = "Tainted data is used in a WebView fetch." or // base URL is nil - sink.getBaseUrl() instanceof NilLiteralExpr and + sink.getBaseUrl().(BuiltinExpr).getValue() = "nil" and message = "Tainted data is used in a WebView fetch without restricting the base URL." or // base URL is also tainted diff --git a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected index d796aa2da25e..de77bf9fda73 100644 --- a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected +++ b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected @@ -1,156 +1,126 @@ #select -| UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | UnsafeWebViewFetch.swift:103:30:103:84 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:106:25:106:25 | data | UnsafeWebViewFetch.swift:105:18:105:72 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:106:25:106:25 | data | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | UnsafeWebViewFetch.swift:109:30:109:53 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:120:25:120:39 | call to getRemoteData() | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:120:25:120:39 | call to getRemoteData() | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:121:25:121:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:121:25:121:25 | remoteString | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:124:25:124:51 | ... .+(_:_:) ... | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:124:25:124:51 | ... .+(_:_:) ... | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:127:25:127:25 | "..." | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:127:25:127:25 | "..." | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:139:25:139:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:139:25:139:25 | remoteString | Tainted data is used in a WebView fetch with a tainted base URL. | -| UnsafeWebViewFetch.swift:141:25:141:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:141:25:141:25 | remoteString | Tainted data is used in a WebView fetch with a tainted base URL. | -| UnsafeWebViewFetch.swift:154:15:154:15 | remoteData | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:154:15:154:15 | remoteData | Tainted data is used in a WebView fetch with a tainted base URL. | -| UnsafeWebViewFetch.swift:167:25:167:39 | call to getRemoteData() | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:167:25:167:39 | call to getRemoteData() | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:168:25:168:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:168:25:168:25 | remoteString | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:171:25:171:51 | ... .+(_:_:) ... | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:171:25:171:51 | ... .+(_:_:) ... | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:174:25:174:25 | "..." | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:174:25:174:25 | "..." | Tainted data is used in a WebView fetch without restricting the base URL. | -| UnsafeWebViewFetch.swift:186:25:186:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:186:25:186:25 | remoteString | Tainted data is used in a WebView fetch with a tainted base URL. | -| UnsafeWebViewFetch.swift:188:25:188:25 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:188:25:188:25 | remoteString | Tainted data is used in a WebView fetch with a tainted base URL. | -| UnsafeWebViewFetch.swift:201:15:201:15 | remoteData | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:201:15:201:15 | remoteData | Tainted data is used in a WebView fetch with a tainted base URL. | -| UnsafeWebViewFetch.swift:210:25:210:25 | htmlData | UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:210:25:210:25 | htmlData | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | UnsafeWebViewFetch.swift:103:30:103:84 | String(...) | UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:106:25:106:28 | data | UnsafeWebViewFetch.swift:105:18:105:72 | String(...) | UnsafeWebViewFetch.swift:106:25:106:28 | data | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | UnsafeWebViewFetch.swift:109:30:109:53 | String(...) | UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:120:25:120:39 | getRemoteData(...) | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:120:25:120:39 | getRemoteData(...) | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:121:25:121:36 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:121:25:121:36 | remoteString | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:124:25:124:59 | ... + ... | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:124:25:124:59 | ... + ... | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:127:25:127:54 | StringInterpolationExpr | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:127:25:127:54 | StringInterpolationExpr | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:167:25:167:39 | getRemoteData(...) | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:167:25:167:39 | getRemoteData(...) | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:168:25:168:36 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:168:25:168:36 | remoteString | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:171:25:171:59 | ... + ... | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:171:25:171:59 | ... + ... | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:174:25:174:54 | StringInterpolationExpr | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:174:25:174:54 | StringInterpolationExpr | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:210:25:210:32 | htmlData | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:210:25:210:32 | htmlData | Tainted data is used in a WebView fetch without restricting the base URL. | edges -| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | provenance | | -| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:120:25:120:39 | call to getRemoteData() | provenance | | -| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | provenance | | -| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:167:25:167:39 | call to getRemoteData() | provenance | | -| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:206:17:206:31 | call to getRemoteData() | provenance | | -| UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:94:10:94:37 | try ... | provenance | | -| UnsafeWebViewFetch.swift:103:30:103:84 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | provenance | | -| UnsafeWebViewFetch.swift:105:18:105:72 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:106:25:106:25 | data | provenance | | -| UnsafeWebViewFetch.swift:109:30:109:53 | call to String.init(contentsOf:) | UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | provenance | | -| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:121:25:121:25 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:124:25:124:51 | ... .+(_:_:) ... | provenance | | -| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:127:25:127:25 | "..." | provenance | | -| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:131:30:131:30 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:135:25:135:25 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:137:25:137:25 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:139:25:139:25 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:141:25:141:25 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:150:24:150:37 | .utf8 | provenance | | -| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:132:52:132:52 | remoteURL [some:0] | provenance | | -| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:138:47:138:47 | remoteURL [some:0] | provenance | | -| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:139:48:139:48 | remoteURL [some:0] | provenance | | -| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:153:85:153:85 | remoteURL [some:0] | provenance | | -| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:154:86:154:86 | remoteURL [some:0] | provenance | | -| UnsafeWebViewFetch.swift:131:30:131:30 | remoteString | UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | provenance | | -| UnsafeWebViewFetch.swift:132:19:132:61 | call to URL.init(string:relativeTo:) [some:0] | UnsafeWebViewFetch.swift:140:47:140:47 | remoteURL2 [some:0] | provenance | | -| UnsafeWebViewFetch.swift:132:19:132:61 | call to URL.init(string:relativeTo:) [some:0] | UnsafeWebViewFetch.swift:141:48:141:48 | remoteURL2 [some:0] | provenance | | -| UnsafeWebViewFetch.swift:132:52:132:52 | remoteURL [some:0] | UnsafeWebViewFetch.swift:132:19:132:61 | call to URL.init(string:relativeTo:) [some:0] | provenance | | -| UnsafeWebViewFetch.swift:138:47:138:47 | remoteURL [some:0] | UnsafeWebViewFetch.swift:138:47:138:56 | ...! | provenance | | -| UnsafeWebViewFetch.swift:139:48:139:48 | remoteURL [some:0] | UnsafeWebViewFetch.swift:139:48:139:57 | ...! | provenance | | -| UnsafeWebViewFetch.swift:140:47:140:47 | remoteURL2 [some:0] | UnsafeWebViewFetch.swift:140:47:140:57 | ...! | provenance | | -| UnsafeWebViewFetch.swift:141:48:141:48 | remoteURL2 [some:0] | UnsafeWebViewFetch.swift:141:48:141:58 | ...! | provenance | | -| UnsafeWebViewFetch.swift:150:19:150:41 | call to Data.init(_:) | UnsafeWebViewFetch.swift:152:15:152:15 | remoteData | provenance | | -| UnsafeWebViewFetch.swift:150:19:150:41 | call to Data.init(_:) | UnsafeWebViewFetch.swift:154:15:154:15 | remoteData | provenance | | -| UnsafeWebViewFetch.swift:150:24:150:37 | .utf8 | UnsafeWebViewFetch.swift:150:19:150:41 | call to Data.init(_:) | provenance | | -| UnsafeWebViewFetch.swift:153:85:153:85 | remoteURL [some:0] | UnsafeWebViewFetch.swift:153:85:153:94 | ...! | provenance | | -| UnsafeWebViewFetch.swift:154:86:154:86 | remoteURL [some:0] | UnsafeWebViewFetch.swift:154:86:154:95 | ...! | provenance | | -| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:168:25:168:25 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:171:25:171:51 | ... .+(_:_:) ... | provenance | | -| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:174:25:174:25 | "..." | provenance | | -| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:178:30:178:30 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:182:25:182:25 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:184:25:184:25 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:186:25:186:25 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:188:25:188:25 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | UnsafeWebViewFetch.swift:197:24:197:37 | .utf8 | provenance | | -| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:179:52:179:52 | remoteURL [some:0] | provenance | | -| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:185:47:185:47 | remoteURL [some:0] | provenance | | -| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:186:48:186:48 | remoteURL [some:0] | provenance | | -| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:200:90:200:90 | remoteURL [some:0] | provenance | | -| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | UnsafeWebViewFetch.swift:201:91:201:91 | remoteURL [some:0] | provenance | | -| UnsafeWebViewFetch.swift:178:30:178:30 | remoteString | UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | provenance | | -| UnsafeWebViewFetch.swift:179:19:179:61 | call to URL.init(string:relativeTo:) [some:0] | UnsafeWebViewFetch.swift:187:47:187:47 | remoteURL2 [some:0] | provenance | | -| UnsafeWebViewFetch.swift:179:19:179:61 | call to URL.init(string:relativeTo:) [some:0] | UnsafeWebViewFetch.swift:188:48:188:48 | remoteURL2 [some:0] | provenance | | -| UnsafeWebViewFetch.swift:179:52:179:52 | remoteURL [some:0] | UnsafeWebViewFetch.swift:179:19:179:61 | call to URL.init(string:relativeTo:) [some:0] | provenance | | -| UnsafeWebViewFetch.swift:185:47:185:47 | remoteURL [some:0] | UnsafeWebViewFetch.swift:185:47:185:56 | ...! | provenance | | -| UnsafeWebViewFetch.swift:186:48:186:48 | remoteURL [some:0] | UnsafeWebViewFetch.swift:186:48:186:57 | ...! | provenance | | -| UnsafeWebViewFetch.swift:187:47:187:47 | remoteURL2 [some:0] | UnsafeWebViewFetch.swift:187:47:187:57 | ...! | provenance | | -| UnsafeWebViewFetch.swift:188:48:188:48 | remoteURL2 [some:0] | UnsafeWebViewFetch.swift:188:48:188:58 | ...! | provenance | | -| UnsafeWebViewFetch.swift:197:19:197:41 | call to Data.init(_:) | UnsafeWebViewFetch.swift:199:15:199:15 | remoteData | provenance | | -| UnsafeWebViewFetch.swift:197:19:197:41 | call to Data.init(_:) | UnsafeWebViewFetch.swift:201:15:201:15 | remoteData | provenance | | -| UnsafeWebViewFetch.swift:197:24:197:37 | .utf8 | UnsafeWebViewFetch.swift:197:19:197:41 | call to Data.init(_:) | provenance | | -| UnsafeWebViewFetch.swift:200:90:200:90 | remoteURL [some:0] | UnsafeWebViewFetch.swift:200:90:200:99 | ...! | provenance | | -| UnsafeWebViewFetch.swift:201:91:201:91 | remoteURL [some:0] | UnsafeWebViewFetch.swift:201:91:201:100 | ...! | provenance | | -| UnsafeWebViewFetch.swift:206:17:206:31 | call to getRemoteData() | UnsafeWebViewFetch.swift:210:25:210:25 | htmlData | provenance | | -| UnsafeWebViewFetch.swift:206:17:206:31 | call to getRemoteData() | UnsafeWebViewFetch.swift:211:25:211:25 | htmlData | provenance | | +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:117:21:117:35 | getRemoteData(...) | provenance | | +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:120:25:120:39 | getRemoteData(...) | provenance | | +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:164:21:164:35 | getRemoteData(...) | provenance | | +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:167:25:167:39 | getRemoteData(...) | provenance | | +| UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:206:17:206:31 | getRemoteData(...) | provenance | | +| UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:94:10:94:37 | try ... | provenance | | +| UnsafeWebViewFetch.swift:103:30:103:84 | String(...) | UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | provenance | | +| UnsafeWebViewFetch.swift:105:6:105:9 | data | UnsafeWebViewFetch.swift:106:25:106:28 | data | provenance | | +| UnsafeWebViewFetch.swift:105:18:105:72 | String(...) | UnsafeWebViewFetch.swift:105:6:105:9 | data | provenance | | +| UnsafeWebViewFetch.swift:109:30:109:53 | String(...) | UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | provenance | | +| UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:121:25:121:36 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:124:36:124:47 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:127:34:127:45 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:131:30:131:41 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:135:25:135:36 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:137:25:137:36 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:139:25:139:36 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:141:25:141:36 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:117:21:117:35 | getRemoteData(...) | UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:124:36:124:47 | remoteString | UnsafeWebViewFetch.swift:124:25:124:59 | ... + ... | provenance | | +| UnsafeWebViewFetch.swift:127:34:127:45 | remoteString | UnsafeWebViewFetch.swift:127:25:127:54 | StringInterpolationExpr | provenance | | +| UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | UnsafeWebViewFetch.swift:138:47:138:55 | remoteURL | provenance | | +| UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | UnsafeWebViewFetch.swift:139:48:139:56 | remoteURL | provenance | | +| UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | UnsafeWebViewFetch.swift:153:85:153:93 | remoteURL | provenance | | +| UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | UnsafeWebViewFetch.swift:154:86:154:94 | remoteURL | provenance | | +| UnsafeWebViewFetch.swift:131:30:131:41 | remoteString | UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | provenance | | +| UnsafeWebViewFetch.swift:138:47:138:55 | remoteURL | UnsafeWebViewFetch.swift:138:47:138:56 | ... ! | provenance | | +| UnsafeWebViewFetch.swift:139:48:139:56 | remoteURL | UnsafeWebViewFetch.swift:139:48:139:57 | ... ! | provenance | | +| UnsafeWebViewFetch.swift:153:85:153:93 | remoteURL | UnsafeWebViewFetch.swift:153:85:153:94 | ... ! | provenance | | +| UnsafeWebViewFetch.swift:154:86:154:94 | remoteURL | UnsafeWebViewFetch.swift:154:86:154:95 | ... ! | provenance | | +| UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:168:25:168:36 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:171:36:171:47 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:174:34:174:45 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:178:30:178:41 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:182:25:182:36 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:184:25:184:36 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:186:25:186:36 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:188:25:188:36 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:164:21:164:35 | getRemoteData(...) | UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | provenance | | +| UnsafeWebViewFetch.swift:171:36:171:47 | remoteString | UnsafeWebViewFetch.swift:171:25:171:59 | ... + ... | provenance | | +| UnsafeWebViewFetch.swift:174:34:174:45 | remoteString | UnsafeWebViewFetch.swift:174:25:174:54 | StringInterpolationExpr | provenance | | +| UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | UnsafeWebViewFetch.swift:185:47:185:55 | remoteURL | provenance | | +| UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | UnsafeWebViewFetch.swift:186:48:186:56 | remoteURL | provenance | | +| UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | UnsafeWebViewFetch.swift:200:90:200:98 | remoteURL | provenance | | +| UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | UnsafeWebViewFetch.swift:201:91:201:99 | remoteURL | provenance | | +| UnsafeWebViewFetch.swift:178:30:178:41 | remoteString | UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | provenance | | +| UnsafeWebViewFetch.swift:185:47:185:55 | remoteURL | UnsafeWebViewFetch.swift:185:47:185:56 | ... ! | provenance | | +| UnsafeWebViewFetch.swift:186:48:186:56 | remoteURL | UnsafeWebViewFetch.swift:186:48:186:57 | ... ! | provenance | | +| UnsafeWebViewFetch.swift:200:90:200:98 | remoteURL | UnsafeWebViewFetch.swift:200:90:200:99 | ... ! | provenance | | +| UnsafeWebViewFetch.swift:201:91:201:99 | remoteURL | UnsafeWebViewFetch.swift:201:91:201:100 | ... ! | provenance | | +| UnsafeWebViewFetch.swift:206:6:206:13 | htmlData | UnsafeWebViewFetch.swift:210:25:210:32 | htmlData | provenance | | +| UnsafeWebViewFetch.swift:206:6:206:13 | htmlData | UnsafeWebViewFetch.swift:211:25:211:32 | htmlData | provenance | | +| UnsafeWebViewFetch.swift:206:17:206:31 | getRemoteData(...) | UnsafeWebViewFetch.swift:206:6:206:13 | htmlData | provenance | | nodes | UnsafeWebViewFetch.swift:94:10:94:37 | try ... | semmle.label | try ... | -| UnsafeWebViewFetch.swift:94:14:94:37 | call to String.init(contentsOf:) | semmle.label | call to String.init(contentsOf:) | +| UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | semmle.label | String(...) | | UnsafeWebViewFetch.swift:103:25:103:84 | try! ... | semmle.label | try! ... | -| UnsafeWebViewFetch.swift:103:30:103:84 | call to String.init(contentsOf:) | semmle.label | call to String.init(contentsOf:) | -| UnsafeWebViewFetch.swift:105:18:105:72 | call to String.init(contentsOf:) | semmle.label | call to String.init(contentsOf:) | -| UnsafeWebViewFetch.swift:106:25:106:25 | data | semmle.label | data | +| UnsafeWebViewFetch.swift:103:30:103:84 | String(...) | semmle.label | String(...) | +| UnsafeWebViewFetch.swift:105:6:105:9 | data | semmle.label | data | +| UnsafeWebViewFetch.swift:105:18:105:72 | String(...) | semmle.label | String(...) | +| UnsafeWebViewFetch.swift:106:25:106:28 | data | semmle.label | data | | UnsafeWebViewFetch.swift:109:25:109:53 | try! ... | semmle.label | try! ... | -| UnsafeWebViewFetch.swift:109:30:109:53 | call to String.init(contentsOf:) | semmle.label | call to String.init(contentsOf:) | -| UnsafeWebViewFetch.swift:117:21:117:35 | call to getRemoteData() | semmle.label | call to getRemoteData() | -| UnsafeWebViewFetch.swift:120:25:120:39 | call to getRemoteData() | semmle.label | call to getRemoteData() | -| UnsafeWebViewFetch.swift:121:25:121:25 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:124:25:124:51 | ... .+(_:_:) ... | semmle.label | ... .+(_:_:) ... | -| UnsafeWebViewFetch.swift:127:25:127:25 | "..." | semmle.label | "..." | -| UnsafeWebViewFetch.swift:131:18:131:42 | call to URL.init(string:) [some:0] | semmle.label | call to URL.init(string:) [some:0] | -| UnsafeWebViewFetch.swift:131:30:131:30 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:132:19:132:61 | call to URL.init(string:relativeTo:) [some:0] | semmle.label | call to URL.init(string:relativeTo:) [some:0] | -| UnsafeWebViewFetch.swift:132:52:132:52 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | -| UnsafeWebViewFetch.swift:135:25:135:25 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:137:25:137:25 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:138:47:138:47 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | -| UnsafeWebViewFetch.swift:138:47:138:56 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:139:25:139:25 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:139:48:139:48 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | -| UnsafeWebViewFetch.swift:139:48:139:57 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:140:47:140:47 | remoteURL2 [some:0] | semmle.label | remoteURL2 [some:0] | -| UnsafeWebViewFetch.swift:140:47:140:57 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:141:25:141:25 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:141:48:141:48 | remoteURL2 [some:0] | semmle.label | remoteURL2 [some:0] | -| UnsafeWebViewFetch.swift:141:48:141:58 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:150:19:150:41 | call to Data.init(_:) | semmle.label | call to Data.init(_:) | -| UnsafeWebViewFetch.swift:150:24:150:37 | .utf8 | semmle.label | .utf8 | -| UnsafeWebViewFetch.swift:152:15:152:15 | remoteData | semmle.label | remoteData | -| UnsafeWebViewFetch.swift:153:85:153:85 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | -| UnsafeWebViewFetch.swift:153:85:153:94 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:154:15:154:15 | remoteData | semmle.label | remoteData | -| UnsafeWebViewFetch.swift:154:86:154:86 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | -| UnsafeWebViewFetch.swift:154:86:154:95 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:164:21:164:35 | call to getRemoteData() | semmle.label | call to getRemoteData() | -| UnsafeWebViewFetch.swift:167:25:167:39 | call to getRemoteData() | semmle.label | call to getRemoteData() | -| UnsafeWebViewFetch.swift:168:25:168:25 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:171:25:171:51 | ... .+(_:_:) ... | semmle.label | ... .+(_:_:) ... | -| UnsafeWebViewFetch.swift:174:25:174:25 | "..." | semmle.label | "..." | -| UnsafeWebViewFetch.swift:178:18:178:42 | call to URL.init(string:) [some:0] | semmle.label | call to URL.init(string:) [some:0] | -| UnsafeWebViewFetch.swift:178:30:178:30 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:179:19:179:61 | call to URL.init(string:relativeTo:) [some:0] | semmle.label | call to URL.init(string:relativeTo:) [some:0] | -| UnsafeWebViewFetch.swift:179:52:179:52 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | -| UnsafeWebViewFetch.swift:182:25:182:25 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:184:25:184:25 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:185:47:185:47 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | -| UnsafeWebViewFetch.swift:185:47:185:56 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:186:25:186:25 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:186:48:186:48 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | -| UnsafeWebViewFetch.swift:186:48:186:57 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:187:47:187:47 | remoteURL2 [some:0] | semmle.label | remoteURL2 [some:0] | -| UnsafeWebViewFetch.swift:187:47:187:57 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:188:25:188:25 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:188:48:188:48 | remoteURL2 [some:0] | semmle.label | remoteURL2 [some:0] | -| UnsafeWebViewFetch.swift:188:48:188:58 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:197:19:197:41 | call to Data.init(_:) | semmle.label | call to Data.init(_:) | -| UnsafeWebViewFetch.swift:197:24:197:37 | .utf8 | semmle.label | .utf8 | -| UnsafeWebViewFetch.swift:199:15:199:15 | remoteData | semmle.label | remoteData | -| UnsafeWebViewFetch.swift:200:90:200:90 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | -| UnsafeWebViewFetch.swift:200:90:200:99 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:201:15:201:15 | remoteData | semmle.label | remoteData | -| UnsafeWebViewFetch.swift:201:91:201:91 | remoteURL [some:0] | semmle.label | remoteURL [some:0] | -| UnsafeWebViewFetch.swift:201:91:201:100 | ...! | semmle.label | ...! | -| UnsafeWebViewFetch.swift:206:17:206:31 | call to getRemoteData() | semmle.label | call to getRemoteData() | -| UnsafeWebViewFetch.swift:210:25:210:25 | htmlData | semmle.label | htmlData | -| UnsafeWebViewFetch.swift:211:25:211:25 | htmlData | semmle.label | htmlData | +| UnsafeWebViewFetch.swift:109:30:109:53 | String(...) | semmle.label | String(...) | +| UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:117:21:117:35 | getRemoteData(...) | semmle.label | getRemoteData(...) | +| UnsafeWebViewFetch.swift:120:25:120:39 | getRemoteData(...) | semmle.label | getRemoteData(...) | +| UnsafeWebViewFetch.swift:121:25:121:36 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:124:25:124:59 | ... + ... | semmle.label | ... + ... | +| UnsafeWebViewFetch.swift:124:36:124:47 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:127:25:127:54 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | +| UnsafeWebViewFetch.swift:127:34:127:45 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | semmle.label | remoteURL | +| UnsafeWebViewFetch.swift:131:30:131:41 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:135:25:135:36 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:137:25:137:36 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:138:47:138:55 | remoteURL | semmle.label | remoteURL | +| UnsafeWebViewFetch.swift:138:47:138:56 | ... ! | semmle.label | ... ! | +| UnsafeWebViewFetch.swift:139:25:139:36 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:139:48:139:56 | remoteURL | semmle.label | remoteURL | +| UnsafeWebViewFetch.swift:139:48:139:57 | ... ! | semmle.label | ... ! | +| UnsafeWebViewFetch.swift:141:25:141:36 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:153:85:153:93 | remoteURL | semmle.label | remoteURL | +| UnsafeWebViewFetch.swift:153:85:153:94 | ... ! | semmle.label | ... ! | +| UnsafeWebViewFetch.swift:154:86:154:94 | remoteURL | semmle.label | remoteURL | +| UnsafeWebViewFetch.swift:154:86:154:95 | ... ! | semmle.label | ... ! | +| UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:164:21:164:35 | getRemoteData(...) | semmle.label | getRemoteData(...) | +| UnsafeWebViewFetch.swift:167:25:167:39 | getRemoteData(...) | semmle.label | getRemoteData(...) | +| UnsafeWebViewFetch.swift:168:25:168:36 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:171:25:171:59 | ... + ... | semmle.label | ... + ... | +| UnsafeWebViewFetch.swift:171:36:171:47 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:174:25:174:54 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | +| UnsafeWebViewFetch.swift:174:34:174:45 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | semmle.label | remoteURL | +| UnsafeWebViewFetch.swift:178:30:178:41 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:182:25:182:36 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:184:25:184:36 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:185:47:185:55 | remoteURL | semmle.label | remoteURL | +| UnsafeWebViewFetch.swift:185:47:185:56 | ... ! | semmle.label | ... ! | +| UnsafeWebViewFetch.swift:186:25:186:36 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:186:48:186:56 | remoteURL | semmle.label | remoteURL | +| UnsafeWebViewFetch.swift:186:48:186:57 | ... ! | semmle.label | ... ! | +| UnsafeWebViewFetch.swift:188:25:188:36 | remoteString | semmle.label | remoteString | +| UnsafeWebViewFetch.swift:200:90:200:98 | remoteURL | semmle.label | remoteURL | +| UnsafeWebViewFetch.swift:200:90:200:99 | ... ! | semmle.label | ... ! | +| UnsafeWebViewFetch.swift:201:91:201:99 | remoteURL | semmle.label | remoteURL | +| UnsafeWebViewFetch.swift:201:91:201:100 | ... ! | semmle.label | ... ! | +| UnsafeWebViewFetch.swift:206:6:206:13 | htmlData | semmle.label | htmlData | +| UnsafeWebViewFetch.swift:206:17:206:31 | getRemoteData(...) | semmle.label | getRemoteData(...) | +| UnsafeWebViewFetch.swift:210:25:210:32 | htmlData | semmle.label | htmlData | +| UnsafeWebViewFetch.swift:211:25:211:32 | htmlData | semmle.label | htmlData | subpaths diff --git a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.qlref b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.qlref index 18d2fc0a49df..b14b06a96d25 100644 --- a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.qlref +++ b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.qlref @@ -1,2 +1,3 @@ -query: queries/Security/CWE-079/UnsafeWebViewFetch.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +query: queries/security/CWE-079/UnsafeWebViewFetch.ql +postprocess: + - utils/test/InlineExpectationsTestQuery.ql diff --git a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift index cba21bcc4554..285e538d1b8a 100644 --- a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift +++ b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift @@ -136,9 +136,9 @@ func testUIWebView() { webview.loadHTMLString(localString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified webview.loadHTMLString(remoteString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified webview.loadHTMLString(localString, baseURL: remoteURL!) // GOOD: the HTML data is local - webview.loadHTMLString(remoteString, baseURL: remoteURL!) // $ Alert + webview.loadHTMLString(remoteString, baseURL: remoteURL!) // $ MISSING: Alert webview.loadHTMLString(localString, baseURL: remoteURL2!) // GOOD: the HTML data is local - webview.loadHTMLString(remoteString, baseURL: remoteURL2!) // $ Alert + webview.loadHTMLString(remoteString, baseURL: remoteURL2!) // $ MISSING: Alert let localRequest = URLRequest(url: localURL!) let remoteRequest = URLRequest(url: remoteURL!) @@ -151,7 +151,7 @@ func testUIWebView() { webview.load(localData, mimeType: "text/html", textEncodingName: "utf-8", baseURL: localSafeURL!) // GOOD: the data is local webview.load(remoteData, mimeType: "text/html", textEncodingName: "utf-8", baseURL: localSafeURL!) // GOOD: a safe baseURL is specified webview.load(localData, mimeType: "text/html", textEncodingName: "utf-8", baseURL: remoteURL!) // GOOD: the HTML data is local - webview.load(remoteData, mimeType: "text/html", textEncodingName: "utf-8", baseURL: remoteURL!) // $ Alert + webview.load(remoteData, mimeType: "text/html", textEncodingName: "utf-8", baseURL: remoteURL!) // $ MISSING: Alert } func testWKWebView() { @@ -183,9 +183,9 @@ func testWKWebView() { webview.loadHTMLString(localString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified webview.loadHTMLString(remoteString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified webview.loadHTMLString(localString, baseURL: remoteURL!) // GOOD: the HTML data is local - webview.loadHTMLString(remoteString, baseURL: remoteURL!) // $ Alert + webview.loadHTMLString(remoteString, baseURL: remoteURL!) // $ MISSING: Alert webview.loadHTMLString(localString, baseURL: remoteURL2!) // GOOD: the HTML data is local - webview.loadHTMLString(remoteString, baseURL: remoteURL2!) // $ Alert + webview.loadHTMLString(remoteString, baseURL: remoteURL2!) // $ MISSING: Alert let localRequest = URLRequest(url: localURL!) let remoteRequest = URLRequest(url: remoteURL!) @@ -198,7 +198,7 @@ func testWKWebView() { webview.load(localData, mimeType: "text/html", characterEncodingName: "utf-8", baseURL: localSafeURL!) // GOOD: the data is local webview.load(remoteData, mimeType: "text/html", characterEncodingName: "utf-8", baseURL: localSafeURL!) // GOOD: a safe baseURL is specified webview.load(localData, mimeType: "text/html", characterEncodingName: "utf-8", baseURL: remoteURL!) // GOOD: the HTML data is local - webview.load(remoteData, mimeType: "text/html", characterEncodingName: "utf-8", baseURL: remoteURL!) // $ Alert + webview.load(remoteData, mimeType: "text/html", characterEncodingName: "utf-8", baseURL: remoteURL!) // $ MISSING: Alert } func testQHelpExamples() { From 5dee595b8a0edb896f2ddfd7e722abf0161f7515 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:38:26 +0000 Subject: [PATCH 04/11] unified: Detect WebView fetches with tainted base URLs Use node-based flowTo instead of flowToExpr, whose unified exprNode adapter is not yet implemented. This restores the UIWebView and WKWebView direct tainted-base-URL cases without changing shared data flow. Preserve all 12 baseline result rows and add two detections. Four relative-URL and Data cases remain explicitly MISSING. Both the focused test and the related JavaScript-evaluation test pass without learning. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql | 7 +++++-- .../CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected | 2 ++ .../CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql index ff774f0349d4..46cc5fb310ac 100644 --- a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql @@ -47,7 +47,7 @@ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { /** * Detect taint flow of taint sources to sinks (and `baseURL` arguments) for this query. - * TODO: Recover the tainted-base-URL paths marked MISSING in the tests. + * TODO: Recover the relative-URL and Data paths marked MISSING in the tests. */ module UnsafeWebViewFetchFlow = TaintTracking::Global; @@ -69,7 +69,10 @@ where message = "Tainted data is used in a WebView fetch without restricting the base URL." or // base URL is also tainted - UnsafeWebViewFetchFlow::flowToExpr(sink.getBaseUrl()) and + exists(DataFlow::Node baseUrl | + baseUrl.asExpr() = sink.getBaseUrl() and + UnsafeWebViewFetchFlow::flowTo(baseUrl) + ) and message = "Tainted data is used in a WebView fetch with a tainted base URL." ) select sink, sourceNode, sinkNode, message diff --git a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected index de77bf9fda73..3402724f5da6 100644 --- a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected +++ b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected @@ -6,10 +6,12 @@ | UnsafeWebViewFetch.swift:121:25:121:36 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:121:25:121:36 | remoteString | Tainted data is used in a WebView fetch without restricting the base URL. | | UnsafeWebViewFetch.swift:124:25:124:59 | ... + ... | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:124:25:124:59 | ... + ... | Tainted data is used in a WebView fetch without restricting the base URL. | | UnsafeWebViewFetch.swift:127:25:127:54 | StringInterpolationExpr | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:127:25:127:54 | StringInterpolationExpr | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:139:25:139:36 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:139:25:139:36 | remoteString | Tainted data is used in a WebView fetch with a tainted base URL. | | UnsafeWebViewFetch.swift:167:25:167:39 | getRemoteData(...) | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:167:25:167:39 | getRemoteData(...) | Tainted data is used in a WebView fetch without restricting the base URL. | | UnsafeWebViewFetch.swift:168:25:168:36 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:168:25:168:36 | remoteString | Tainted data is used in a WebView fetch without restricting the base URL. | | UnsafeWebViewFetch.swift:171:25:171:59 | ... + ... | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:171:25:171:59 | ... + ... | Tainted data is used in a WebView fetch without restricting the base URL. | | UnsafeWebViewFetch.swift:174:25:174:54 | StringInterpolationExpr | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:174:25:174:54 | StringInterpolationExpr | Tainted data is used in a WebView fetch without restricting the base URL. | +| UnsafeWebViewFetch.swift:186:25:186:36 | remoteString | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:186:25:186:36 | remoteString | Tainted data is used in a WebView fetch with a tainted base URL. | | UnsafeWebViewFetch.swift:210:25:210:32 | htmlData | UnsafeWebViewFetch.swift:94:14:94:37 | String(...) | UnsafeWebViewFetch.swift:210:25:210:32 | htmlData | Tainted data is used in a WebView fetch without restricting the base URL. | edges | UnsafeWebViewFetch.swift:94:10:94:37 | try ... | UnsafeWebViewFetch.swift:117:21:117:35 | getRemoteData(...) | provenance | | diff --git a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift index 285e538d1b8a..bc385292ee3b 100644 --- a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift +++ b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift @@ -136,7 +136,7 @@ func testUIWebView() { webview.loadHTMLString(localString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified webview.loadHTMLString(remoteString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified webview.loadHTMLString(localString, baseURL: remoteURL!) // GOOD: the HTML data is local - webview.loadHTMLString(remoteString, baseURL: remoteURL!) // $ MISSING: Alert + webview.loadHTMLString(remoteString, baseURL: remoteURL!) // $ Alert webview.loadHTMLString(localString, baseURL: remoteURL2!) // GOOD: the HTML data is local webview.loadHTMLString(remoteString, baseURL: remoteURL2!) // $ MISSING: Alert @@ -183,7 +183,7 @@ func testWKWebView() { webview.loadHTMLString(localString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified webview.loadHTMLString(remoteString, baseURL: localURL!) // GOOD: a presumed safe baseURL is specified webview.loadHTMLString(localString, baseURL: remoteURL!) // GOOD: the HTML data is local - webview.loadHTMLString(remoteString, baseURL: remoteURL!) // $ MISSING: Alert + webview.loadHTMLString(remoteString, baseURL: remoteURL!) // $ Alert webview.loadHTMLString(localString, baseURL: remoteURL2!) // GOOD: the HTML data is local webview.loadHTMLString(remoteString, baseURL: remoteURL2!) // $ MISSING: Alert From 83559232a8735502f4a0cdc3d692fef673033f99 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:47:44 +0000 Subject: [PATCH 05/11] unified: Clarify WebView base URL security guidance Explain that about:blank avoids local relative-URL resolution rather than promising to block absolute remote URLs. Keep navigation and content restrictions distinct from setting a trusted base URL. Validate the help XML and local samples. The external Web View XSS reference was checked with the restricted link-checking agent and remains unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelp b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelp index 2efd5d35d5f3..2b1ca4a58958 100644 --- a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelp +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelp @@ -18,7 +18,7 @@ -

    To fix the problem, we set the baseURL to about:blank. This ensures that an attacker cannot resolve URLs that point to the local file system, or to web servers under their control.

    +

    To fix the problem, we set the baseURL to about:blank. This avoids resolving relative URLs against the application's local file system. A base URL is not a general navigation restriction: absolute remote URLs still need appropriate navigation and content controls.

    From 9ce9d0a4f4ecec4760e9a9aee9a0f9ccfb254373 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 19:16:57 +0000 Subject: [PATCH 06/11] Unified: Edit comments and plan. --- unified/ql/lib/ext/webview.model.json | 1 + .../queries/security/CWE-079/UnsafeWebViewFetch.ql | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/unified/ql/lib/ext/webview.model.json b/unified/ql/lib/ext/webview.model.json index b95bccbf55d1..fee6e0358bde 100644 --- a/unified/ql/lib/ext/webview.model.json +++ b/unified/ql/lib/ext/webview.model.json @@ -7,6 +7,7 @@ }, "data": [ // namespace, type, subtypes, name, signature, ext, input, kind, provenance + // note that the baseURL argument is currently recognized by name, not encoded here. ["", "UIWebView", true, "loadHTMLString(_:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"], ["", "WKWebView", true, "loadHTMLString(_:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"], ["", "UIWebView", true, "load(_:mimeType:textEncodingName:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"], diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql index 46cc5fb310ac..5c9b4d3e6509 100644 --- a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql @@ -14,7 +14,9 @@ import unified -/** A modeled WebView fetch, with its associated base URL if present. */ +/** + * A modeled WebView fetch, with its associated base URL if present. + */ private class UnsafeWebViewFetchSink extends DataFlow::Node { UnsafeWebViewFetchSink() { Models::isSink(this, "webview-fetch") } @@ -27,8 +29,7 @@ private class UnsafeWebViewFetchSink extends DataFlow::Node { } /** - * A taint configuration from taint sources to sinks (and `baseURL` arguments) - * for this query. + * A taint configuration from taint sources to sinks for this query, and to `baseURL` arguments. */ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { predicate isSource(DataFlow::Node node) { Models::isSource(node, _) } @@ -42,13 +43,12 @@ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { none() // can't override location accurately because of secondary use in select. + // TODO: review this, perhaps split into two flows and use two sink models even??? } } -/** - * Detect taint flow of taint sources to sinks (and `baseURL` arguments) for this query. - * TODO: Recover the relative-URL and Data paths marked MISSING in the tests. - */ +// TODO: Recover the relative-URL and Data paths marked MISSING in the tests. + module UnsafeWebViewFetchFlow = TaintTracking::Global; import UnsafeWebViewFetchFlow::PathGraph From 5c3ae7502139f18e51dc9080289b860ff454a94c Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:52:50 +0000 Subject: [PATCH 07/11] Unified: Model the base URLs, rather than using a hardcoded argument name. --- shared/mad/codeql/mad/ModelValidation.qll | 3 ++- unified/ql/lib/ext/webview.model.json | 7 +++++-- .../security/CWE-079/UnsafeWebViewFetch.ql | 21 ++++++++++++------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/shared/mad/codeql/mad/ModelValidation.qll b/shared/mad/codeql/mad/ModelValidation.qll index a5e64c434992..cbe350c2d768 100644 --- a/shared/mad/codeql/mad/ModelValidation.qll +++ b/shared/mad/codeql/mad/ModelValidation.qll @@ -42,7 +42,8 @@ module KindValidation { "cors-origin", "mongodb.sink", "system-prompt-injection", "user-prompt-injection", // Swift-only currently, but may be shared in the future "database-store", "format-string", "hash-iteration-count", "predicate-injection", - "preferences-store", "tls-protocol-version", "transmission", "webview-fetch", "xxe", + "preferences-store", "tls-protocol-version", "transmission", "webview-fetch", + "webview-baseurl", "xxe", // Go-only currently, but may be shared in the future "jwt", // CPP-only currently diff --git a/unified/ql/lib/ext/webview.model.json b/unified/ql/lib/ext/webview.model.json index fee6e0358bde..a72e2986d99d 100644 --- a/unified/ql/lib/ext/webview.model.json +++ b/unified/ql/lib/ext/webview.model.json @@ -7,11 +7,14 @@ }, "data": [ // namespace, type, subtypes, name, signature, ext, input, kind, provenance - // note that the baseURL argument is currently recognized by name, not encoded here. ["", "UIWebView", true, "loadHTMLString(_:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"], + ["", "UIWebView", true, "loadHTMLString(_:baseURL:)", "", "", "Argument[baseURL:]", "webview-baseurl", "manual"], ["", "WKWebView", true, "loadHTMLString(_:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"], + ["", "WKWebView", true, "loadHTMLString(_:baseURL:)", "", "", "Argument[baseURL:]", "webview-baseurl", "manual"], ["", "UIWebView", true, "load(_:mimeType:textEncodingName:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"], - ["", "WKWebView", true, "load(_:mimeType:characterEncodingName:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"] + ["", "UIWebView", true, "load(_:mimeType:textEncodingName:baseURL:)", "", "", "Argument[baseURL:]", "webview-baseurl", "manual"], + ["", "WKWebView", true, "load(_:mimeType:characterEncodingName:baseURL:)", "", "", "Argument[0]", "webview-fetch", "manual"], + ["", "WKWebView", true, "load(_:mimeType:characterEncodingName:baseURL:)", "", "", "Argument[baseURL:]", "webview-baseurl", "manual"] ] } ] diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql index 5c9b4d3e6509..8dacdb575c1e 100644 --- a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql @@ -20,10 +20,16 @@ import unified private class UnsafeWebViewFetchSink extends DataFlow::Node { UnsafeWebViewFetchSink() { Models::isSink(this, "webview-fetch") } - Expr getBaseUrl() { + /** + * Gets a base URL argument of this WebView fetch. + */ + DataFlow::Node getABaseUrl() { + // `result` is a `webview-baseurl` sink that's part of the same + // call as this `webview-fetch` sink. exists(CallExpr call | - this.asExpr() = call.getAnArgument().getValue() and - result = call.getNamedArgument("baseURL") + Models::isSink(result, "webview-baseurl") and + call.getAnArgument().getValue() = this.asExpr() and + call.getAnArgument().getValue() = result.asExpr() ) } } @@ -37,7 +43,7 @@ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { predicate isSink(DataFlow::Node node) { exists(UnsafeWebViewFetchSink sink | node = sink or - node.asExpr() = sink.getBaseUrl() + node = sink.getABaseUrl() ) } @@ -48,7 +54,6 @@ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { } // TODO: Recover the relative-URL and Data paths marked MISSING in the tests. - module UnsafeWebViewFetchFlow = TaintTracking::Global; import UnsafeWebViewFetchFlow::PathGraph @@ -61,16 +66,16 @@ where sink = sinkNode.getNode() and ( // no base URL - not exists(sink.getBaseUrl()) and + not exists(sink.getABaseUrl()) and message = "Tainted data is used in a WebView fetch." or // base URL is nil - sink.getBaseUrl().(BuiltinExpr).getValue() = "nil" and + sink.getABaseUrl().asExpr().(BuiltinExpr).getValue() = "nil" and message = "Tainted data is used in a WebView fetch without restricting the base URL." or // base URL is also tainted exists(DataFlow::Node baseUrl | - baseUrl.asExpr() = sink.getBaseUrl() and + baseUrl = sink.getABaseUrl() and UnsafeWebViewFetchFlow::flowTo(baseUrl) ) and message = "Tainted data is used in a WebView fetch with a tainted base URL." From 12f7752897972f27364273cabcd9425c28c55854 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:52:50 +0000 Subject: [PATCH 08/11] Unified: Split the data flow configuration in two (this is probably more readable and cleans up observeDiffInformedIncrementalMode). --- .../security/CWE-079/UnsafeWebViewFetch.ql | 36 +++++++++-------- .../UnsafeWebViewFetch.expected | 40 ------------------- 2 files changed, 20 insertions(+), 56 deletions(-) diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql index 8dacdb575c1e..0c4d07e66ad9 100644 --- a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql @@ -15,7 +15,7 @@ import unified /** - * A modeled WebView fetch, with its associated base URL if present. + * A modeled WebView fetch. */ private class UnsafeWebViewFetchSink extends DataFlow::Node { UnsafeWebViewFetchSink() { Models::isSink(this, "webview-fetch") } @@ -35,22 +35,14 @@ private class UnsafeWebViewFetchSink extends DataFlow::Node { } /** - * A taint configuration from taint sources to sinks for this query, and to `baseURL` arguments. + * A taint configuration from taint sources to sinks for this query. */ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { predicate isSource(DataFlow::Node node) { Models::isSource(node, _) } - predicate isSink(DataFlow::Node node) { - exists(UnsafeWebViewFetchSink sink | - node = sink or - node = sink.getABaseUrl() - ) - } + predicate isSink(DataFlow::Node node) { exists(UnsafeWebViewFetchSink sink | node = sink) } - predicate observeDiffInformedIncrementalMode() { - none() // can't override location accurately because of secondary use in select. - // TODO: review this, perhaps split into two flows and use two sink models even??? - } + predicate observeDiffInformedIncrementalMode() { any() } } // TODO: Recover the relative-URL and Data paths marked MISSING in the tests. @@ -58,6 +50,21 @@ module UnsafeWebViewFetchFlow = TaintTracking::Global; import UnsafeWebViewFetchFlow::PathGraph +/** + * A taint configuration from taint sources to base URL arguments of WebView fetches. + */ +module BaseUrlConfig implements DataFlow::ConfigSig { + predicate isSource(DataFlow::Node node) { Models::isSource(node, _) } + + predicate isSink(DataFlow::Node node) { node = any(UnsafeWebViewFetchSink sink).getABaseUrl() } + + predicate observeDiffInformedIncrementalMode() { + none() // only used as secondary configuration + } +} + +module BaseUrlFlow = TaintTracking::Global; + from UnsafeWebViewFetchFlow::PathNode sourceNode, UnsafeWebViewFetchFlow::PathNode sinkNode, UnsafeWebViewFetchSink sink, string message @@ -74,10 +81,7 @@ where message = "Tainted data is used in a WebView fetch without restricting the base URL." or // base URL is also tainted - exists(DataFlow::Node baseUrl | - baseUrl = sink.getABaseUrl() and - UnsafeWebViewFetchFlow::flowTo(baseUrl) - ) and + BaseUrlFlow::flowTo(sink.getABaseUrl()) and message = "Tainted data is used in a WebView fetch with a tainted base URL." ) select sink, sourceNode, sinkNode, message diff --git a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected index 3402724f5da6..bbdfe8b07f3f 100644 --- a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected +++ b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected @@ -27,7 +27,6 @@ edges | UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:121:25:121:36 | remoteString | provenance | | | UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:124:36:124:47 | remoteString | provenance | | | UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:127:34:127:45 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:131:30:131:41 | remoteString | provenance | | | UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:135:25:135:36 | remoteString | provenance | | | UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:137:25:137:36 | remoteString | provenance | | | UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | UnsafeWebViewFetch.swift:139:25:139:36 | remoteString | provenance | | @@ -35,19 +34,9 @@ edges | UnsafeWebViewFetch.swift:117:21:117:35 | getRemoteData(...) | UnsafeWebViewFetch.swift:117:6:117:17 | remoteString | provenance | | | UnsafeWebViewFetch.swift:124:36:124:47 | remoteString | UnsafeWebViewFetch.swift:124:25:124:59 | ... + ... | provenance | | | UnsafeWebViewFetch.swift:127:34:127:45 | remoteString | UnsafeWebViewFetch.swift:127:25:127:54 | StringInterpolationExpr | provenance | | -| UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | UnsafeWebViewFetch.swift:138:47:138:55 | remoteURL | provenance | | -| UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | UnsafeWebViewFetch.swift:139:48:139:56 | remoteURL | provenance | | -| UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | UnsafeWebViewFetch.swift:153:85:153:93 | remoteURL | provenance | | -| UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | UnsafeWebViewFetch.swift:154:86:154:94 | remoteURL | provenance | | -| UnsafeWebViewFetch.swift:131:30:131:41 | remoteString | UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | provenance | | -| UnsafeWebViewFetch.swift:138:47:138:55 | remoteURL | UnsafeWebViewFetch.swift:138:47:138:56 | ... ! | provenance | | -| UnsafeWebViewFetch.swift:139:48:139:56 | remoteURL | UnsafeWebViewFetch.swift:139:48:139:57 | ... ! | provenance | | -| UnsafeWebViewFetch.swift:153:85:153:93 | remoteURL | UnsafeWebViewFetch.swift:153:85:153:94 | ... ! | provenance | | -| UnsafeWebViewFetch.swift:154:86:154:94 | remoteURL | UnsafeWebViewFetch.swift:154:86:154:95 | ... ! | provenance | | | UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:168:25:168:36 | remoteString | provenance | | | UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:171:36:171:47 | remoteString | provenance | | | UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:174:34:174:45 | remoteString | provenance | | -| UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:178:30:178:41 | remoteString | provenance | | | UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:182:25:182:36 | remoteString | provenance | | | UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:184:25:184:36 | remoteString | provenance | | | UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | UnsafeWebViewFetch.swift:186:25:186:36 | remoteString | provenance | | @@ -55,15 +44,6 @@ edges | UnsafeWebViewFetch.swift:164:21:164:35 | getRemoteData(...) | UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | provenance | | | UnsafeWebViewFetch.swift:171:36:171:47 | remoteString | UnsafeWebViewFetch.swift:171:25:171:59 | ... + ... | provenance | | | UnsafeWebViewFetch.swift:174:34:174:45 | remoteString | UnsafeWebViewFetch.swift:174:25:174:54 | StringInterpolationExpr | provenance | | -| UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | UnsafeWebViewFetch.swift:185:47:185:55 | remoteURL | provenance | | -| UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | UnsafeWebViewFetch.swift:186:48:186:56 | remoteURL | provenance | | -| UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | UnsafeWebViewFetch.swift:200:90:200:98 | remoteURL | provenance | | -| UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | UnsafeWebViewFetch.swift:201:91:201:99 | remoteURL | provenance | | -| UnsafeWebViewFetch.swift:178:30:178:41 | remoteString | UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | provenance | | -| UnsafeWebViewFetch.swift:185:47:185:55 | remoteURL | UnsafeWebViewFetch.swift:185:47:185:56 | ... ! | provenance | | -| UnsafeWebViewFetch.swift:186:48:186:56 | remoteURL | UnsafeWebViewFetch.swift:186:48:186:57 | ... ! | provenance | | -| UnsafeWebViewFetch.swift:200:90:200:98 | remoteURL | UnsafeWebViewFetch.swift:200:90:200:99 | ... ! | provenance | | -| UnsafeWebViewFetch.swift:201:91:201:99 | remoteURL | UnsafeWebViewFetch.swift:201:91:201:100 | ... ! | provenance | | | UnsafeWebViewFetch.swift:206:6:206:13 | htmlData | UnsafeWebViewFetch.swift:210:25:210:32 | htmlData | provenance | | | UnsafeWebViewFetch.swift:206:6:206:13 | htmlData | UnsafeWebViewFetch.swift:211:25:211:32 | htmlData | provenance | | | UnsafeWebViewFetch.swift:206:17:206:31 | getRemoteData(...) | UnsafeWebViewFetch.swift:206:6:206:13 | htmlData | provenance | | @@ -85,20 +65,10 @@ nodes | UnsafeWebViewFetch.swift:124:36:124:47 | remoteString | semmle.label | remoteString | | UnsafeWebViewFetch.swift:127:25:127:54 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | | UnsafeWebViewFetch.swift:127:34:127:45 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:131:6:131:14 | remoteURL | semmle.label | remoteURL | -| UnsafeWebViewFetch.swift:131:30:131:41 | remoteString | semmle.label | remoteString | | UnsafeWebViewFetch.swift:135:25:135:36 | remoteString | semmle.label | remoteString | | UnsafeWebViewFetch.swift:137:25:137:36 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:138:47:138:55 | remoteURL | semmle.label | remoteURL | -| UnsafeWebViewFetch.swift:138:47:138:56 | ... ! | semmle.label | ... ! | | UnsafeWebViewFetch.swift:139:25:139:36 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:139:48:139:56 | remoteURL | semmle.label | remoteURL | -| UnsafeWebViewFetch.swift:139:48:139:57 | ... ! | semmle.label | ... ! | | UnsafeWebViewFetch.swift:141:25:141:36 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:153:85:153:93 | remoteURL | semmle.label | remoteURL | -| UnsafeWebViewFetch.swift:153:85:153:94 | ... ! | semmle.label | ... ! | -| UnsafeWebViewFetch.swift:154:86:154:94 | remoteURL | semmle.label | remoteURL | -| UnsafeWebViewFetch.swift:154:86:154:95 | ... ! | semmle.label | ... ! | | UnsafeWebViewFetch.swift:164:6:164:17 | remoteString | semmle.label | remoteString | | UnsafeWebViewFetch.swift:164:21:164:35 | getRemoteData(...) | semmle.label | getRemoteData(...) | | UnsafeWebViewFetch.swift:167:25:167:39 | getRemoteData(...) | semmle.label | getRemoteData(...) | @@ -107,20 +77,10 @@ nodes | UnsafeWebViewFetch.swift:171:36:171:47 | remoteString | semmle.label | remoteString | | UnsafeWebViewFetch.swift:174:25:174:54 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | | UnsafeWebViewFetch.swift:174:34:174:45 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:178:6:178:14 | remoteURL | semmle.label | remoteURL | -| UnsafeWebViewFetch.swift:178:30:178:41 | remoteString | semmle.label | remoteString | | UnsafeWebViewFetch.swift:182:25:182:36 | remoteString | semmle.label | remoteString | | UnsafeWebViewFetch.swift:184:25:184:36 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:185:47:185:55 | remoteURL | semmle.label | remoteURL | -| UnsafeWebViewFetch.swift:185:47:185:56 | ... ! | semmle.label | ... ! | | UnsafeWebViewFetch.swift:186:25:186:36 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:186:48:186:56 | remoteURL | semmle.label | remoteURL | -| UnsafeWebViewFetch.swift:186:48:186:57 | ... ! | semmle.label | ... ! | | UnsafeWebViewFetch.swift:188:25:188:36 | remoteString | semmle.label | remoteString | -| UnsafeWebViewFetch.swift:200:90:200:98 | remoteURL | semmle.label | remoteURL | -| UnsafeWebViewFetch.swift:200:90:200:99 | ... ! | semmle.label | ... ! | -| UnsafeWebViewFetch.swift:201:91:201:99 | remoteURL | semmle.label | remoteURL | -| UnsafeWebViewFetch.swift:201:91:201:100 | ... ! | semmle.label | ... ! | | UnsafeWebViewFetch.swift:206:6:206:13 | htmlData | semmle.label | htmlData | | UnsafeWebViewFetch.swift:206:17:206:31 | getRemoteData(...) | semmle.label | getRemoteData(...) | | UnsafeWebViewFetch.swift:210:25:210:32 | htmlData | semmle.label | htmlData | From c2e0a8dea037081dc65df9c3eb1d020088eb34f8 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:00:26 +0000 Subject: [PATCH 09/11] Unified: Remove the TODO, the causes have been identified and written up in issues. --- unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql | 1 - 1 file changed, 1 deletion(-) diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql index 0c4d07e66ad9..be2848f86a0c 100644 --- a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql @@ -45,7 +45,6 @@ module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { predicate observeDiffInformedIncrementalMode() { any() } } -// TODO: Recover the relative-URL and Data paths marked MISSING in the tests. module UnsafeWebViewFetchFlow = TaintTracking::Global; import UnsafeWebViewFetchFlow::PathGraph From 6761d04fd019df8ac6fa44cb4cd527700d0acd04 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:29:28 +0000 Subject: [PATCH 10/11] Unified: Tiny CodeQL cleanup. --- unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql index be2848f86a0c..25e2ceacaf9c 100644 --- a/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql +++ b/unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql @@ -40,7 +40,7 @@ private class UnsafeWebViewFetchSink extends DataFlow::Node { module UnsafeWebViewFetchConfig implements DataFlow::ConfigSig { predicate isSource(DataFlow::Node node) { Models::isSource(node, _) } - predicate isSink(DataFlow::Node node) { exists(UnsafeWebViewFetchSink sink | node = sink) } + predicate isSink(DataFlow::Node node) { node = any(UnsafeWebViewFetchSink sink) } predicate observeDiffInformedIncrementalMode() { any() } } From 34e51dbf1c7b26b23cc9e166990a7c61c4394015 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:34:23 +0000 Subject: [PATCH 11/11] Unified: Clean up test annotation. --- .../CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift index bc385292ee3b..c7b0ccc253bd 100644 --- a/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift +++ b/unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift @@ -117,7 +117,7 @@ func testUIWebView() { let remoteString = getRemoteData() webview.loadHTMLString(localString, baseURL: nil) // GOOD: the HTML data is local - webview.loadHTMLString(getRemoteData(), baseURL: nil) // $ Alert // BAD: HTML contains remote input, may access local secrets + webview.loadHTMLString(getRemoteData(), baseURL: nil) // $ Alert (HTML contains remote input, may access local secrets) webview.loadHTMLString(remoteString, baseURL: nil) // $ Alert webview.loadHTMLString("" + localStringFragment + "", baseURL: nil) // GOOD: the HTML data is local