Swift FoundationApplication · Apple

CVE-2022-3918

HIGH · 8.8 CVSS v3.1 Published 2023-01-20
Fix available
A fix is available. Upgrade to 5.7.3 or later.
See remediation →
94/100
Remediation priority · Urgent
Remotely reachable Zero-click

Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.

NVD · unedited
A program using FoundationNetworking in swift-corelibs-foundation is potentially vulnerable to CRLF ( ) injection in URLRequest headers. In this vulnerability, a client can insert one or several CRLF sequences into a URLRequest header value. When that request is sent via URLSession to an HTTP server, the server may interpret the content after the CRLF as extra headers, or even a second request. For example, consider a URLRequest to http://example.com/ with the GET method. Suppose we set the URLRequest header "Foo" to the value "Bar Extra-Header: Added GET /other HTTP/1.1". When this request is sent, it will appear to the server as two requests: GET / HTTP/1.1 Foo: Bar Extra-Header: Added GET /other HTTP/1.1 In this manner, the client is able to inject extra headers and craft an entirely new request to a separate path, despite only making one API call in URLSession. If a developer has total control over the request and its headers, this vulnerability may not pose a threat. However, this vulnerability escalates if un-sanitized user input is placed in header values. If so, a malicious user could inject new headers or requests to an intermediary or backend server. Developers should be especially careful to sanitize user input in this case, or upgrade their version of swift-corelibs-foundation to include the patch below.

Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.

dbcve analysis · high confidence

CRLF injection vulnerability in swift-corelibs-foundation allows attackers to inject newline characters into URLRequest header values, potentially splitting a single HTTP request into multiple requests or injecting arbitrary headers. This occurs because the library does not sanitize or reject CRLF sequences in header values before sending them via URLSession.

MitigationSanitize all user input before using it in URLRequest header values, rejecting or stripping any CRLF sequences. Alternatively, upgrade to a patched version of swift-corelibs-foundation that implements validation to reject headers containing CRLF.

Verify against the referenced sources before acting — the references below are authoritative for this CVE, this summary is not.

Affected products & versions What the vendor confirmedThe version ranges the vendor confirmed as vulnerable. If your version sits inside a range here, treat yourself as exposed until you have upgraded.

NVD · CPE data
Swift FoundationApplication
Affected:< 5.7.3

CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.

From the vector
Attack vector
Network
Complexity
Low
Privileges
Low
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Am I affected? How to checkSteps we derive from the advisory and the affected-version data, so you can decide whether this CVE reaches your setup. They are a guide, not a scan — your own configuration is the authority.

dbcve checks

Work through these to decide whether this CVE applies to you.

  1. Identify Swift Foundation implementation in use
    Determine if your application uses swift-corelibs-foundation (open source) versus Apple Foundation (macOS/iOS). Check your dependency manifest (Package.swift, Podfile, or similar) for 'swift-corelibs-foundation' or check runtime by inspecting the loaded library. On Linux, run 'swift --version' and check the Foundation library path.
    Affected if Using swift-corelibs-foundation (open source version) rather than Apple Foundation on macOS/iOS
  2. Determine installed Swift version
    Run 'swift --version' on the command line or programmatically get ProcessInfo.processInfo.swiftVersion. This returns the Swift language version which correlates to the Foundation version bundled with it.
    Affected if Swift version is below 5.7.3 (check against the affected range < 5.7.3)
  3. Inspect code for URLRequest header manipulation
    Search source code for instances of URLRequest, URLSession, or HTTPURLResponse where headers are set. Look for code that assigns user-supplied strings (query parameters, form input, database values, API responses) to HTTPHeader fields like 'allHTTPHeaderFields', 'value(forHTTPHeaderField:)', or direct property assignment.
    Affected if Code passes unsanitized user input directly into URLRequest header values without filtering CRLF sequences
  4. Check for input sanitization functions
    Review any utility functions, middleware, or validation layers that process data before using it in HTTP requests. Look for presence of validation logic that strips or rejects newline characters (\r, \n, \r\n) from header-bound data.
    Affected if No sanitization logic exists that explicitly rejects or strips CRLF sequences from data before header assignment

You are affected if your application uses swift-corelibs-foundation with Swift version below 5.7.3 AND passes external/unsanitized input into URLRequest header values.

Generated from the published advisory. Verify against your own configuration.

Check your environment

Paste your version and any relevant configuration and it will be compared against the affected criteria above. Do not include secrets or credentials.

AI-assisted, checked against the advisory. Informational, not a guarantee.

Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.

dbcve · scoped
Upgrade available Upgrade to 5.7.3 or later
Fixed in 5.7.3
Interim mitigation

Sanitize all user input before using it in URLRequest header values, rejecting or stripping any CRLF sequences. Alternatively, upgrade to a patched version of swift-corelibs-foundation that implements validation to reject headers containing CRLF.

Recommended fix High confidence

Swift Foundation 5.7.3

  1. Upgrade Swift Foundation to version 5.7.3 or later
  2. Verify the upgrade by checking the FoundationNetworking library version
  3. Test application to ensure URLSession requests handle header values correctly and that the CRLF injection is mitigated
  4. If using a package manager (Swift Package Manager), update the Package.swift dependency to specify swift-corelibs-foundation version 5.7.3 or later
  5. For CocoaPods users, update the Podfile to request Foundation version 5.7.3 or newer and run pod update
  6. For Carthage users, update Cartfile to fetch the corrected version and rebuild

Generated from the published advisory — verify against the referenced sources before acting.

Fix this in Swift Foundation Scoped from the published advisory
  • Consultation3.0 h
  • Implementation6.0 h
  • Testing3.0 h
  • Review / QA2.0 h
14.0 hours of engineering $2,490
Get the upgrade done

An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $3,984.

Scan for this in your stack

Free · runs locally
dbcve dependency scanner

Check whether your project pulls in CVE-2022-3918 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.

References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.

Primary sources

Practitioner notes

Contributed

Peer-ranked notes from engineers who’ve handled CVE-2022-3918 in production — separate from our analysis above.

No notes yet

Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.

What this is

A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.

What belongs here
  • Verified mitigations, workarounds, and config changes
  • Version or environment caveats, and links to real fixes
  • No weaponised exploit code, or anything meant to cause harm
  • No spam, self-promotion, credentials, or personal data