Repository navigation
Description
Target Language
swift
Query Name (Optional)
CredentialAndDataExposure
Query Type
Security
Query Description
AI Scan reported 7 medium and low-severity CWE-200, CWE-316, CWE-522, CWE-922 (credential and data exposure) finding(s) in Swift public synthetic repositories that the baseline CodeQL default-setup scan did not report. Gap categories: missing-query, query-absent. Existing queries considered: none.
Why CodeQL appears to have missed these (unverified until reproduced with a test database):
- No installed query covers sensitive values copied to the global pasteboard without expiration or local-only options.
- Session token is derived by encrypting email and password with a static key, a weak token design with no existing Swift query.
- An app delegate that does not obscure the window on backgrounding is a missing-API check, expressible as an audit style query.
- Keychain queries without a restrictive kSecAttrAccessible value have no existing Swift query.
- Sensitive responses cached by returnCacheDataElseLoad have no covering query.
- Sensitive data lingering in a long-lived property without being cleared is a lifecycle pattern with no existing Swift query.
Linked findings (gap-key: swift/query-create/credential-and-data-exposure)
| Repo | CWE | Severity | AI scan alert | Summary |
|---|---|---|---|---|
| Swift.nV | CWE-200 | medium | https://github.com/codeql-forks-felickz/Swift.nV/security/code-scanning/38 | The copy action writes the plaintext decrypted value to UIPasteboard.general and does not set an expiration date, clear it, or use a local-only pasteboard. The secret can remain available to other applications/pasteboard readers and to the user after locking or leaving the secret manager, defeating the app's access control for copied credentials. |
| OversecuredVulnerableiOSApp | CWE-522 | medium | https://github.com/codeql-forks-felickz/OversecuredVulnerableiOSApp/security/code-scanning/17 | On successful authentication the app builds the session token by concatenating the email and password and encrypting them with a static key |
| iGoat-Swift | CWE-200 | medium | https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/49 | The app has screens that display password-reset answers and payment data, but AppDelegate does not obscure the window when the application r |
| iGoat-Swift | CWE-922 | low | https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/39 | KeychainPasswordItem.keychainQuery(withService:account:accessGroup:) builds every SecItemAdd/SecItemUpdate/SecItemCopyMatching query |
| iGoat-Swift | CWE-922 | medium | https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/26 | The request for key material explicitly uses .returnCacheDataElseLoad with the default URL session, allowing the HTTP response containing |
| iGoat-Swift | CWE-316 | medium | https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/31 | After payment, the full card number is copied into a long-lived view-controller property and neither that property nor the input field is cl |
| iGoat-Swift | CWE-200 | medium | https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/56 | The view collects password-reset security answers but does not obscure or clear its text fields when the application enters the background. |
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 Create
- Decision: Create a new CodeQL query. No existing query covers these patterns (most findings are gap type
query-absentormissing-query). Because coverage of lower-severity patterns can be heuristic, target Community Packs unless precision is shown to be high enough for github/codeql. - Recommended actions across the findings: write-new-query (7)
Patterns in this gap
background-snapshot-exposure(2 findings), for example iGoat-Swift iGoat-Swift/iGoat-Swift/AppDelegate.swiftmissing-query(1 finding), for example Swift.nV Swift.nV/NVEditItemViewController.swiftcredential-derived-session-token(1 finding), for example OversecuredVulnerableiOSApp OVIA/Network/NetworkCalls.swiftkeychain-accessibility(1 finding), for example iGoat-Swift iGoat-Swift/iGoat-Swift/Source/Exercises/InsecureLocalDataStorage/KeychainAnalyze/KeychainPasswordItem.swiftsensitive-response-caching(1 finding), for example iGoat-Swift iGoat-Swift/iGoat-Swift/Source/Exercises/InsecureLocalDataStorage/WebKit Cache/WebkitCacheExerciseVC.swiftsensitive-data-retained-in-memory(1 finding), for example iGoat-Swift iGoat-Swift/iGoat-Swift/Source/Exercises/Memory Management/MemoryManagementVC.swift
Finding details
Each finding below has its own context so the agent can work from this issue alone.
1. Swift.nV Swift.nV/NVEditItemViewController.swift:203 (CWE-200, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/Swift.nV/security/code-scanning/38
- AI Scan message: The copy action writes the plaintext decrypted value to
UIPasteboard.generaland does not set an expiration date, clear it, or use a local-only pasteboard. The secret can remain available to other applications/pasteboard readers and to the user after locking or leaving the secret manager, defeating the app's access control for copied credentials. - Why CodeQL appears to miss it: missing-query: No installed query covers sensitive values copied to the global pasteboard without expiration or local-only options.
- Recommended action from the comparison: write-new-query (classification confidence: medium)
2. OversecuredVulnerableiOSApp OVIA/Network/NetworkCalls.swift:21 (CWE-522, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/OversecuredVulnerableiOSApp/security/code-scanning/17
- AI Scan message: On successful authentication the app builds the session token by concatenating the email and password and encrypting them with a static key
- Context for the agent: A Swift network call builds a session token by concatenating email and password and encrypting with a hard-coded key. CodeQL would need a query linking password sources and a constant key to a stored or returned token.
- Why CodeQL appears to miss it: query-absent: Session token is derived by encrypting email and password with a static key, a weak token design with no existing Swift query.
- Recommended action from the comparison: write-new-query (classification confidence: low)
3. iGoat-Swift iGoat-Swift/iGoat-Swift/AppDelegate.swift:10 (CWE-200, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/49
- AI Scan message: The app has screens that display password-reset answers and payment data, but AppDelegate does not obscure the window when the application r
- Context for the agent: A Swift AppDelegate does not implement applicationWillResignActive or similar to hide sensitive screens. CodeQL would need an absence query over app delegate lifecycle methods.
- Why CodeQL appears to miss it: query-absent: An app delegate that does not obscure the window on backgrounding is a missing-API check, expressible as an audit style query.
- Recommended action from the comparison: write-new-query (classification confidence: low)
4. iGoat-Swift iGoat-Swift/iGoat-Swift/Source/Exercises/InsecureLocalDataStorage/KeychainAnalyze/KeychainPasswordItem.swift:163 (CWE-922, low)
- AI Scan alert: https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/39
- AI Scan message:
KeychainPasswordItem.keychainQuery(withService:account:accessGroup:)builds everySecItemAdd/SecItemUpdate/SecItemCopyMatchingquery - Context for the agent: A Swift keychain helper builds query dictionaries for add, update and copy without setting an accessibility attribute. CodeQL would need a query on missing or weak kSecAttrAccessible in keychain item dictionaries.
- Why CodeQL appears to miss it: query-absent: Keychain queries without a restrictive kSecAttrAccessible value have no existing Swift query.
- Recommended action from the comparison: write-new-query (classification confidence: medium)
5. iGoat-Swift iGoat-Swift/iGoat-Swift/Source/Exercises/InsecureLocalDataStorage/WebKit Cache/WebkitCacheExerciseVC.swift:45 (CWE-922, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/26
- AI Scan message: The request for key material explicitly uses
.returnCacheDataElseLoadwith the default URL session, allowing the HTTP response containing - Context for the agent: A Swift controller requests key material with returnCacheDataElseLoad on the default session. CodeQL would need an audit query for cache policies on requests carrying sensitive data.
- Why CodeQL appears to miss it: query-absent: Sensitive responses cached by returnCacheDataElseLoad have no covering query.
- Recommended action from the comparison: write-new-query (classification confidence: low)
6. iGoat-Swift iGoat-Swift/iGoat-Swift/Source/Exercises/Memory Management/MemoryManagementVC.swift:18 (CWE-316, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/31
- AI Scan message: After payment, the full card number is copied into a long-lived view-controller property and neither that property nor the input field is cl
- Context for the agent: MemoryManagementVC.swift:18 copies a full card number from a text field into a view-controller property that is never cleared. CodeQL would need a query for sensitive values stored in long-lived properties with no reset path; precision is likely audit level.
- Why CodeQL appears to miss it: query-absent: Sensitive data lingering in a long-lived property without being cleared is a lifecycle pattern with no existing Swift query.
- Recommended action from the comparison: write-new-query (classification confidence: low)
7. iGoat-Swift iGoat-Swift/iGoat-Swift/Source/Exercises/SideChannelDataLeaks/Backgrounding/BackgroundingExerciseVC.swift:3 (CWE-200, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/iGoat-Swift/security/code-scanning/56
- AI Scan message: The view collects password-reset security answers but does not obscure or clear its text fields when the application enters the background.
- Context for the agent: BackgroundingExerciseVC.swift:3 collects security answers in text fields but never hides them in applicationDidEnterBackground. CodeQL would need a structural audit query for sensitive input views lacking a background-obscuring handler.
- Why CodeQL appears to miss it: query-absent: Failing to obscure sensitive views on backgrounding is a UI lifecycle check with no existing Swift query.
- Recommended action from the comparison: write-new-query (classification confidence: low)
Expected Severity
Medium
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.
CWE/CVE Reference (Optional)
CWE-200, CWE-316, CWE-522, CWE-922
References (Optional)
https://cwe.mitre.org/data/definitions/200.html
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
Copilot commentedon Oct 31, 2026
The agent encountered an error and was unable to start working on this issue: Please try again later, or contact support if the problem persists. (Request id: F340:12A606:456BCC0:E3DEC41:6AE56313)
felickz commentedon Nov 3, 2026
Upstream triage
precision:lowAudit-grade or weak signal. 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: #352
Why. Six unrelated checks share one low-precision audit query. Most depend on identifier names (sensitive, decrypt, token, security answer) and on whole-file or whole-program absence checks (no kSecAttrAccessible, property never cleared, no backgrounding hook) that real apps satisfy elsewhere. The stock Swift suite has no overlap, but nothing here is precise enough for github/codeql. Fit for separate experimental Community Packs audit queries.
lowin the pull request). Six unrelated checks in one query. Most rely on identifier-name regexps (SensitiveExpr, decrypt/plaintext, token/session, security answer) or whole-file and whole-program absence checks (no kSecAttrAccessible, never cleared, no backgrounding hook).Concerns, overlap and next steps
False-positive concerns
Performance concerns
Heuristics used
What an upstream change would look like. Split into single-purpose audit queries under swift/src/<category>/ in Community Packs (the Swift pack has no queries yet, so wire them into suites/swift.qls) with tests in swift/test/. No github/codeql change.
Before opening an upstream pull request
Split note. Closest to reusable: the kSecAttrAccessibleAlways reference check and the pasteboard flow check. The default-keychain, backgrounding, cache-policy and retained-property checks are heuristic audit logic and should stay experimental or be dropped.
This is a recommendation only. A human reviews it before any pull request is opened against
github/codeqlor the Community Packs repository.