Repository navigation
Conversation
1 task done
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Enhance detection coverage for CWE-79 XSS in Swift
[UPDATE QUERY] Swift: report local user input reaching Oct 31, 2026
swift/unsafe-webview-fetch sinks
7 of 8 tasks
There was a problem hiding this comment.
🟡 Changes recommended
The documented Swift-only pack installation command fails because the installer’s language allowlist does not include Swift.
1 open issue
What changed in this PR
Adds a custom Swift query to detect local user input reaching unsafe WebView fetches, complementing the upstream remote-input query without changing it.
Changes:
- Adds local-source taint tracking using upstream sinks, barriers, and base-URL reporting rules.
- Introduces Swift source and test packs with positive and negative inline-expectation cases.
- Adds query help and a change note. Swift tests still require a macOS run.
| File | Description |
|---|---|
languages/swift/custom/test/UnsafeWebViewFetchLocalInput/UnsafeWebViewFetchLocalInputTest.ql |
Checks results against inline expectations. |
languages/swift/custom/test/UnsafeWebViewFetchLocalInput/UnsafeWebViewFetchLocalInputTest.expected |
Expects no inline-expectation mismatches. |
languages/swift/custom/test/UnsafeWebViewFetchLocalInput/test.swift |
Adds vulnerable and safe WebView test cases. |
languages/swift/custom/test/qlpack.yml |
Defines the Swift test pack. |
languages/swift/custom/src/UnsafeWebViewFetchLocalInput/UnsafeWebViewFetchLocalInput.qll |
Shares local-input tracking and reporting logic. |
languages/swift/custom/src/UnsafeWebViewFetchLocalInput/UnsafeWebViewFetchLocalInput.ql |
Defines the security query and path results. |
languages/swift/custom/src/UnsafeWebViewFetchLocalInput/UnsafeWebViewFetchLocalInput.md |
Documents detection and remediation. |
languages/swift/custom/src/qlpack.yml |
Defines the Swift query pack. |
languages/swift/custom/src/change-notes/2026-10-31-unsafe-webview-fetch-local-input.md |
Announces the new query. |
Review effort: Balanced
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

📝 Query Update
languages/swift/custom/src/UnsafeWebViewFetchLocalInput/UnsafeWebViewFetchLocalInput.ql(complements upstreamswift/unsafe-webview-fetch)🎯 Changes
What Changed
swift/custom/unsafe-webview-fetch-local-input. It uses upstreamswift/unsafe-webview-fetchunchanged, with the same sinks, barriers, extra flow steps and base-URL reporting rules. The only difference is that its source isLocalFlowSourceinstead ofRemoteFlowSource.UnsafeWebViewFetchLocalInput.qll). Holds the config, the flow module and anunsafeWebViewFetchLocalInput(sink, message)predicate. The query and the test share this predicate.languages-swift-custom-srcandlanguages-swift-custom-test. This repo had no Swift directory before..md) and anewQuerychange note.Why This Change
The issue guessed that
UITextField.textisn't modeled. It already is, inswift-allframeworks/UIKit/UITextField.qll, but as alocalsource.swift/unsafe-webview-fetchonly acceptsRemoteFlowSource, so local input never reaches its sinks. Swift has no threat-model setting that could turnlocalsources on, so changing configuration can't close the gap. A custom query has to change the source set.Remote sources are left out on purpose so this query's alerts don't overlap with the standard query's.
Impact
New alerts on
UIWebView/WKWebViewloadHTMLStringandload(...)calls when local user input reaches them and the base URL is nil, missing, or built from that input. Results from the standard query are unchanged.🔍 Before vs. After
The pattern from iGoat-Swift, reduced to a test case:
Previous Behavior
No alert.
UITextField.textis aLocalFlowSource, whichswift/unsafe-webview-fetchignores.New Behavior
Reported by
swift/custom/unsafe-webview-fetch-local-input: "Local user input is used in a WebView fetch without restricting the base URL."🧪 Testing
test/UnsafeWebViewFetchLocalInput/is an inline-expectation test:MakeTestwith an empty.expected.Positive cases:
WKWebViewUITextFieldDelegatereplacement-string parameterNegative cases:
about:blankbase URLplaceholder, which isn't a sourceNew/updated test cases added
All tests pass. The test has not been run: the Swift extractor only works on macOS, so a macOS run of
codeql test run -- UnsafeWebViewFetchLocalInput/is required.Regression tests validated
No unintended side effects
📊 Impact Analysis
mediumbecause injecting through the device's own UI is lower risk than remote input.📋 Checklist
🔗 References