Repository navigation
Description
Query File Path
swift/unsafe-webview-fetch
Update Type
Enhanced detection coverage
Issue Description
AI Scan reported 1 medium-severity CWE-79 (xss response splitting) finding(s) in Swift public synthetic repositories that the baseline CodeQL default-setup scan did not report. Gap categories: missing-source. Existing queries considered: swift/unsafe-webview-fetch.
Why CodeQL appears to have missed these (unverified until reproduced with a test database):
- Text from a UI text field concatenated into HTML for loadHTMLString is not reported, likely because UITextField text is not a modeled source.
Linked findings (gap-key: swift/query-update/xss-response-splitting)
| Repo | CWE | Severity | AI scan alert | Summary |
|---|---|---|---|---|
| iGoat-Swift | CWE-79 | medium | https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/6 | Text entered by the user is concatenated into an HTML document and passed to loadHTMLString without HTML encoding or script restrictions. |
Findings come from AI Scan on public synthetic apps. Hypotheses above are unverified until reproduced with a test database. Verify first whether CodeQL already covers a case (for example via a different query or threat model) before adding code.
Handling decision
- Type: Query Update
- Decision: Update existing CodeQL queries. The queries named above already target this weakness class; the findings show missing flow steps, sinks, sources, barriers or scope handling. Extend the smallest existing query or model instead of adding a new query.
- Recommended actions across the findings: extend-existing-query (1)
Patterns in this gap
webview-html-ui-input(1 finding), for example iGoat-Swift iGoat-Swift/iGoat-Swift/Source/Exercises/Injection Flaws/XSS/CrossSiteScriptingExerciseVC.swift
Finding details
Each finding below has its own context so the agent can work from this issue alone.
1. iGoat-Swift iGoat-Swift/iGoat-Swift/Source/Exercises/Injection Flaws/XSS/CrossSiteScriptingExerciseVC.swift:8 (CWE-79, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/6
- AI Scan message: Text entered by the user is concatenated into an HTML document and passed to
loadHTMLStringwithout HTML encoding or script restrictions. - Context for the agent: A Swift view controller concatenates text from a text field into an HTML string passed to loadHTMLString. CodeQL would need UI text field input as a source for the web view XSS sink.
- Why CodeQL appears to miss it: missing-source: Text from a UI text field concatenated into HTML for loadHTMLString is not reported, likely because UITextField text is not a modeled source.
- Existing CodeQL queries considered: swift/unsafe-webview-fetch
- Recommended action from the comparison: extend-existing-query (classification confidence: medium)
Proposed Solution
- Reproduce each linked finding with a minimal synthetic test case and confirm the baseline result.
- Identify the missing source, sink, summary or scope condition and extend the smallest model or query that fixes it.
- Add positive and negative tests and a change note.
- Check the false-positive rate on the other linked findings before widening.
Code Examples
See the linked alerts above for the vulnerable pattern; reduce each to a minimal test case with a safe counterpart that should not alert.
Breaking Change?
No - backward compatible
References (Optional)
https://cwe.mitre.org/data/definitions/79.html
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
felickz commentedon Nov 3, 2026
Upstream triage
precision:mediumRelies on heuristics or accepted over-approximation. Community Packs, always tags:experimental.
tags:experimental
Goes to Community Packs: performance, false-positive or synthetic-only concerns.
Community Packs, experimental. Recommended for the Community Packs repository, not
github/codeql. The issue is labeledtags:experimentalfor this.Linked pull request: #333
Why. The PR reruns the stock unsafe-webview-fetch sinks with LocalFlowSource, not RemoteFlowSource. Local sources include the stock contentsOfFile heuristic, so bundled HTML read with String(contentsOfFile:) and loaded with a nil baseURL would alert, and typed text is the user's own input (self-XSS). Sibling stock queries use FlowSource, but changing this high-precision stock query would affect all users. Fit for experimental Community Packs.
mediumin the pull request). Flow uses stock sinks, barriers and steps, but sources are every LocalFlowSource, including the stock contentsOfFile heuristic and typed UI text. Bundled HTML templates and editor previews would alert; the tests cover neither.Concerns, overlap and next steps
False-positive concerns
Heuristics used
What an upstream change would look like. Community Packs swift/src/<category>/UnsafeWebViewFetchLocalInput.ql reusing the stock extensions, sources narrowed to UITextField/UITextView text; tests in swift/test/. A github/codeql patch (FlowSource in UnsafeWebViewFetchQuery.qll) would change a stock query for all users.
Before opening an upstream pull request
Change from the initial guess. When this issue was opened the coarse destination guess was
github/codeql. Reading the actual pull request changed it to Community Packs.This is a recommendation only. A human reviews it before any pull request is opened against
github/codeqlor the Community Packs repository.