Repository navigation
Conversation
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>
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>
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>
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>
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>
…ore readable and cleans up observeDiffInformedIncrementalMode).
|
QHelp previews: unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelpUnsafe WebView fetchFetching data in a web view without restricting the base URL may allow an attacker to access sensitive local data, for example using RecommendationWhen loading HTML into a web view, always set the ExampleIn the following example, a call to let webview = UIWebView()
...
webview.loadHTMLString(htmlData, baseURL: nil) // BADTo fix the problem, we set the let webview = UIWebView()
...
webview.loadHTMLString(htmlData, baseURL: URL(string: "about:blank")) // GOODReferences
|
|
DCA LGTM, and there are no semantic merge conflicts with the model format change in this PR. So ready for review. |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved findings show false positives from overly broad source and receiver matching, plus missed unsafe cases involving nil aliases, local-file base URLs, and diff-informed filtering.
5 open issues
What changed in this PR
Ports Swift’s Unsafe WebView fetch query to unified analysis as unified/swift/unsafe-webview-fetch, with separate taint analysis for HTML content and base URLs.
Changes:
- Add the query, WebView sink models, and base-URL sink-kind validation.
- Add query help with safe and unsafe examples.
- Add regression fixtures and expected paths, documenting four known missing alerts.
| File | Description |
|---|---|
unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.swift |
Tests safe and unsafe UIWebView and WKWebView loads. |
unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.qlref |
Connects the query to inline-expectation checking. |
unified/ql/test/query-tests/security/CWE-079/UnsafeWebViewFetch/UnsafeWebViewFetch.expected |
Records expected alerts and flow paths. |
unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetchGood.swift |
Demonstrates an about:blank base URL. |
unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetchBad.swift |
Demonstrates an unsafe nil base URL. |
unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.ql |
Implements the unified query and base-URL analysis. |
unified/ql/src/queries/security/CWE-079/UnsafeWebViewFetch.qhelp |
Explains risks, recommendations, and mitigation limits. |
unified/ql/lib/ext/webview.model.json |
Models WebView content and base-URL arguments as sinks. |
shared/mad/codeql/mad/ModelValidation.qll |
Accepts the new webview-baseurl sink kind. |
Review effort: Max (adaptive)

Port the "Unsafe WebView fetch" query to unified, as
unified/swift/unsafe-webview-fetch. Developed with Copilot + the porting skill + GPT-6.1 Sol High Effort. Some cleanup afterwards - in particular the way the original query handledbaseURLwasn't great, it's considerably better now IMO. The fourMISSINGresults in the test have been diagnosed and written up as issues (not fixed here).DCA run to follow...