Skip to content

Unified: Improve unified/swift/cleartext-logging - #23185

Open
geoffw0 wants to merge 8 commits into
github:mainfrom
geoffw0:unifiedlogging
Open

geoffw0 wants to merge 8 commits into
github:mainfrom
geoffw0:unifiedlogging

Conversation

@geoffw0

@geoffw0 geoffw0 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Improvements to unified/swift/cleartext-logging. Not high priority work, except that I want to use this query as a basis for other cleartext-* queries, and I’d rather fix as much as I can of it first.

  • more test cases.
  • upgrade logic for finding sensitive name clues in qualifier / access paths (e.g. a.sensitive.b). We use additional flow steps now, as in the original Swift implementation, rather than hacks in the sensitive data library.
  • add models-as-data and heuristic sinks (as in the original query). There's still one more sink type I haven't done properly because it's a bit of a tangent, and we're doing OK without it.

DCA run to follow. There's a small chance the additional flow in isAdditionalFlowStep could cause performance problems, though something similar was OK in original Swift, and it does give better results.

@geoffw0
geoffw0 requested a review from a team as a code owner November 20, 2026 14:37
@geoffw0 geoffw0 added no-change-note-required This PR does not need a change note Unified labels Nov 20, 2026
Copilot AI adaptive review requested due to automatic review settings November 20, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved detection gaps miss sensitive-named constructor calls and optional strings, while false positives affect Boolean members, default-redacted OSLog messages, and methods on unrelated receiver types.

5 open issues
What changed in this PR

Improves unified Swift cleartext-logging detection and refactors sensitive-source handling for reuse by other cleartext queries.

Changes:

  • Moves access-chain propagation into query-level taint steps.
  • Adds modeled logging sinks and name/type-based sink heuristics.
  • Expands Swift regression cases and updates expected alerts and flow paths.
File Description
unified/​ql/​test/​query-tests/​security/​CWE-312/​CleartextLogging/​CleartextLoggingTest.swift Adds array, optional, nested-access, and logging-sink cases.
unified/​ql/​test/​query-tests/​security/​CWE-312/​CleartextLogging/​CleartextLogging.expected Updates expected alerts and data-flow paths.
unified/​ql/​src/​queries/​security/​CWE-312/​CleartextLogging.ql Adds sink recognition and access-chain taint propagation.
unified/​ql/​lib/​codeql/​unified/​security/​SensitiveData.qll Narrows source classification to sensitive identifier and member references.

Review effort: Max (adaptive)

)
) and
e = call.getAnArgument().getValue() and
TypeInference::inferType(e).asClass().getName() = ["String", "NSString"] and

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into this.

nodeTo.asExpr().(MemberAccessExpr).getBase() = nodeFrom.asExpr()
or
// if `a` is sensitive, then `a()` is also sensitive.
nodeTo.asExpr().(CallExpr).getCallee() = nodeFrom.asExpr()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the test and restored the old SensitiveDataCall class. Unless there's something cleverer we can do, it looks like we need both.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants