Skip to content

Rust: Add neutral models for spurious actix-web connection_info sink models - #22884

Open
johncarmack1984 wants to merge 3 commits into
github:mainfrom
johncarmack1984:rust-actix-connection-info-neutral
Open

johncarmack1984 wants to merge 3 commits into
github:mainfrom
johncarmack1984:rust-actix-connection-info-neutral

Conversation

@johncarmack1984

Copy link
Copy Markdown

The generated actix-web models make HttpRequest::connection_info an alloc-layout and a log-injection sink, and so do the methods built on it: full_url, url_for, url_for_static, ResourceMap::url_for, ServiceRequest::connection_info and the ConnectionInfo extractor. connection_info only reads the host, scheme and client address off the request and caches them there. It logs nothing, and the strings it allocates are copies of header values, which the HTTP layer already bounds. The rows look like they come from ConnectionInfo::new, which carries the same pair and is crate-private, so it gets no row here. So rust/uncontrolled-allocation-size and rust/log-injection flag every handler that reads the connection info. I hit this on maplibre/martin, where the handlers that build TileJSON and style URLs call req.connection_info().

This adds neutral sink models for those seven methods next to the existing actix-web models. Each mirrors a pair of generated rows, and none of the seven has any other sink kind, so nothing else is suppressed.

The first commit adds an actix-web handler to the CWE-117 and CWE-770 query tests that calls six of the methods, with today's results tagged SPURIOUS (the other .expected changes in that commit are model renumbering). The second adds the models, and both .expected files come back to what they are on main. ServiceRequest::connection_info isn't in the test, since no source reaches a ServiceRequest there. codeql test run passes on both directories and on the other three actix-web test directories with CLI 2.27.3. The test lockfiles pin actix-rt 2.11.0 like the other actix-web tests, because a fresh resolution picks actix-server 2.8.0 with actix-rt 2.15.0, which doesn't compile. DCA should show fewer results from both queries on actix-web projects that read the connection info.

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.

🔵 Needs a closer look

The security-query sink suppressions and new dependency pins need human confirmation of the reported test results and broader analysis impact.

No open issues 🎉

What changed in this PR

This PR refines CodeQL’s Rust actix-web models to reduce false positives when handlers read connection information or build URLs.

Changes:

  • Adds neutral sink models for seven APIs to suppress spurious allocation-size and log-injection results.
  • Adds regression cases for both affected queries, with actix-web dependencies and pinned lockfiles.
  • Documents the analysis improvement in a change note.
File Description
rust/​ql/​test/​query-tests/​security/​CWE-770/​options.yml Adds the actix-web test dependency.
rust/​ql/​test/​query-tests/​security/​CWE-770/​main.rs Exercises six APIs as allocation-size regression cases.
rust/​ql/​test/​query-tests/​security/​CWE-770/​Cargo.lock Locks the added dependencies, including actix-rt 2.11.0.
rust/​ql/​test/​query-tests/​security/​CWE-117/​options.yml Adds the actix-web test dependency.
rust/​ql/​test/​query-tests/​security/​CWE-117/​main.rs Exercises six APIs as log-injection regression cases.
rust/​ql/​test/​query-tests/​security/​CWE-117/​Cargo.lock Locks the added dependencies, including actix-rt 2.11.0.
rust/​ql/​lib/​codeql/​rust/​frameworks/​actix-web.model.yml Adds seven neutral sink overrides.
rust/​ql/​lib/​change-notes/​2026-10-25-neutral-models-actix-connection-info.md Documents the reduction in false positives.

Review effort: Max

CommanderStorm pushed a commit to maplibre/martin that referenced this pull request Oct 25, 2026
CodeQL's request-taint queries see nothing inside the 12 route handlers
that `#[hotpath::measure]` instruments, the tile, TileJSON, catalog,
font, sprite and style handlers among them. Its Rust extractor turns on
every Cargo feature unless told otherwise
([docs](https://github.com/github/codeql/blob/codeql-cli/v2.27.3/rust/codeql-extractor.yml#L48-L54)),
so hotpath's profiling is on, and the attribute then hands each async
body to `hotpath::functions::measure_async` as an `async` block
([macro](https://github.com/hotpath-rs/hotpath/blob/4eb2e398d4a3bab902faa1809e6cfca48c1e919e/crates/hotpath-macros/src/lib_on.rs#L861-L864))
that CodeQL can't follow into. The CodeQL job now gives the extractor
every workspace feature except the hotpath ones, read from `cargo
metadata`, the way `just check` already leaves them out of its feature
matrix.

Seeing into those handlers, CodeQL flags their `req.connection_info()`
calls, as it did [the OGC one on
#3763](#3763 (comment)):
its generated actix-web model makes `connection_info` an allocation and
log sink, though it only reads the host, scheme and client address off
the request. A neutral model in `.github/codeql/extensions`, which [code
scanning loads on its
own](https://docs.github.com/en/code-security/how-tos/find-and-fix-code-vulnerabilities/manage-your-configuration/edit-default-setup#extending-coverage-for-a-repository),
cancels those generated sinks the way github/codeql#22871 does for
`Vec`, until github/codeql#22884 ships the same rows upstream. With CI's
suite and CodeQL 2.27.3, main goes from 7 results to 6, the OGC one
included.

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

documentation external-contribution Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants