Skip to content

[Query Create]: CWE-918 HIGH - Rust: new query for ssrf reflection injection #140

Open

Description

@felickz

Target Language

rust

Query Name (Optional)

SsrfReflectionInjection

Query Type

Security

Query Description

AI Scan reported 2 high-severity CWE-918 (ssrf reflection injection) finding(s) in Rust public synthetic repositories that the baseline CodeQL default-setup scan did not report. Gap categories: missing-query. Existing queries considered: none.

Why CodeQL appears to have missed these (unverified until reproduced with a test database):

  • The installed Rust security catalog has no query for this vulnerability class; useful coverage requires a new query and, for framework APIs, supporting models.

Linked findings (gap-key: rust/query-create/ssrf-reflection-injection)

Repo CWE Severity AI scan alert Summary
rust-vulnerable-apps CWE-918 high https://github.com/codeql-forks-felickz/rust-vulnerable-apps/security/code-scanning/16 The inbound request URL, whose authority is derived from attacker-controlled HTTP request metadata, is passed directly to reqwest. An attacker can select internal or external destinations and have the server fetch and return their response.
rust-vulnerable-apps CWE-918 high https://github.com/codeql-forks-felickz/rust-vulnerable-apps/security/code-scanning/17 The URL path parameter is interpolated into the destination used by reqwest without an allowlist or address validation. An attacker can cause requests to attacker-selected HTTPS hosts; default redirect following can also reach otherwise disallowed schemes or internal destinations.

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.

Expected Severity

High

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-918

References (Optional)

https://cwe.mitre.org/data/definitions/918.html

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    enhancement
    on Oct 16, 2026
  2. added
    severity:high
    on Oct 16, 2026
  3. self-assigned this
    on Oct 16, 2026
  4. added
    precision:medium
    tags:experimental
    on Nov 3, 2026
  5. felickz commented on Nov 3, 2026

    @felickz
    Author

    Upstream triage

    precision:medium Relies 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 labeled tags:experimental for this.

    Linked pull request: #144

    Why. Stock rust/request-forgery already exists; this query copies its configuration and adds iron request-field sources, a regexp-based fixed-host format! barrier and a query-local async-capture flow step. The iron source targets a niche framework and the barrier is a text heuristic, so it is not a clean patch for the product query. Keep it as an experimental community query; the barrier and async gap are better raised as separate library changes.

    Change Patch to an existing query or library
    Target Stock rust/request-forgery: iron field sources, fixed-host format! barrier, async-block capture flow step
    Precision assessed medium (declared high in the pull request). Sources and sinks come from the stock RequestForgery module. Additions: a regexp over format! template text (barrier only), whole-field iron sources (url, headers, body) and a query-local async capture step. Tiered medium conservatively; real FP risk is mostly stock-level.
    Real-world basis partial. Core reuses stock reqwest sinks and warp closure sources (general). The iron source targets an old niche framework (iron 0.6.1 in the test) and fetching the inbound req.url is a contrived pattern.
    Stock overlap partial. rust/request-forgery and RequestForgeryExtensions exist in rust-queries 0.1.42 / rust-all 0.2.21 and upstream main; the PR copies its config and adds three pieces. Stock has no iron model.
    Concerns, overlap and next steps

    False-positive concerns

    • Fixed-host URLs built by concatenation, push_str or Url::join are not barriers; path-only control is still reported
    • iron url, headers and body are sources wholesale; an allowlisted or validated value is still reported

    Performance concerns

    • getParentNode+ closures over the AST in FixedHostFormatBarrier and asyncBlockCaptureStep; unmeasured on large databases
    • Extra flow step for every captured variable read inside async blocks

    Heuristics used

    • regexp over the format! template literal text (isFixedHostTemplate)
    • macro path text compare: getPath().getText() = "format"

    What an upstream change would look like. Community Packs: rust/src/<category>/ExtendedRequestForgery.ql with tests under rust/test. If a piece goes to github/codeql later: a Barrier in RequestForgeryExtensions.qll (tests in rust/ql/test/query-tests/security/CWE-918, lib change note), an iron model, and a dataflow fix for async captures.

    Before opening an upstream pull request

    • Show a true positive on a real project (iron or warp app), not only on the synthetic app
    • Replace the format! template regexp with a structural check, or measure its precision
    • Profile the getParentNode+ closures on a large Rust database
    • Raise the async capture gap against the shared dataflow library instead of a query-local step

    Split note. Three separable parts: iron sources (niche, better as a model), fixed-host format! barrier (possible patch to RequestForgeryExtensions.qll if made structural), async capture step (dataflow library). Whole-PR destination is Community Packs.

    This is a recommendation only. A human reviews it before any pull request is opened against github/codeql or the Community Packs repository.

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

Metadata

Metadata

Labels

CWE-918enhancementprecision:mediumquery-createseverity:hightags:experimental

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions