attackmap-analyzer-swift
Swift ecosystem analyzer plugin for AttackMap.
Auto-discovered via the attackmap.analyzers entry point once installed.
Status: experimental. Vapor / Hummingbird routes with route-level auth, the iOS/macOS app attack surface, and a SwiftPM + CocoaPods + Carthage dependency SBOM. Requires an AttackMap core with the app-surface contract (mlaify/AttackMap#347).
Install
uv tool install attackmap --with attackmap-analyzer-swift # from PyPI
# or: pip install attackmap-analyzer-swift (installs attackmap too)
# or from source:
pip install git+https://github.com/mlaify/attackmap-analyzer-swift.git # alongside attackmap
The analyzer is experimental and opt-in (enabled_by_default=False): installing
it does not make it run on every scan. Select it explicitly:
attackmap analyze /path/to/swift/project -m swift
Files are walked with attackmap.sdk.iter_repo_files: .build/, DerivedData/,
Pods/, Carthage/ and AttackMap's shared skip list (build/, .git/,
node_modules/, ...) are pruned by their name inside the repo, and symlinks out
of the repo are not followed.
What it does today
-
SwiftPM detection — recognizes
Package.swift,.xcodeproj/.xcworkspace, and.swiftsources; emits aSwiftPMframework hint. -
Server-side routes (AttackMap#187) — Vapor 4 and Hummingbird 1.x/2.x route registrations (
app.get("users", ":id"),on(.POST, ...),webSocket/ws,router.get("/x"), chainedgroup.get(use:).post(use:)), with prefixes fromgrouped(...)/group(...)(closures, bindings and chains), and from where aRouteCollectionor controller is mounted (register(collection:),addRoutes(to:),addRoutes(_:atPath:)) when every mount in the same Swift package agrees. Each route carriesauth,guardsandguard_evidence(AttackMap#256):requiredwhen Vapor'sX.guardMiddleware()/X.redirectMiddleware(...), Hummingbird'sIsAuthenticatedMiddlewareor an*Authorization*Middlewareapplies, or the handler callsreq.auth.require(...)/context.requireIdentity()or guards on the caller's identity with a 401. An authenticator alone (UserAuthenticator(),SessionAuthenticator) leaves the routeunknown, since it only identifies callers who send credentials. Role checks in the handler (guard user.roles.contains(.admin)) are reported as guards. Paths the code computes (SiteURL.faq.pathComponents) are kept as$(SiteURL.faq), and an unknown mount as$(TypeName). Test targets (Tests/,*Tests/) are skipped. -
iOS/macOS app attack surface (AttackMap#188) — reported as
AppSurfaceIssues, which core turns intoapple-*findings with CWE/OWASP ids.Info.plist(XML or binary, read withplistlib, never executed): App Transport Security exceptions, i.e.NSAllowsArbitraryLoads(medium; low when a scoped key makes iOS 10+ ignore it),...InWebContent/...ForMedia, and per-domainNSExceptionAllowsInsecureHTTPLoadsor a TLS minimum below 1.2 (low). Each customCFBundleURLSchemesscheme is an entry point and anapple-custom-url-schemefinding (low); the handlers (application(_:open:options:),scene(_:openURLContexts:),.onOpenURL) are reported as entry points.*.entitlements:cs.disable-library-validation,allow-dyld-environment-variables,allow-unsigned-executable-memory,disable-executable-page-protection(medium);get-task-allowoutside a Debug/Dev entitlements file (low);applinks:universal-link domains as entry points.*.xcconfig: secret-named build settings (API_KEY,CLIENT_SECRET,AUTH_TOKEN) with a literal value (not$(...), not a placeholder), reported as hard-coded secrets with the value masked.- Swift code:
evaluateJavaScript("...'\(value)'...")where a value is interpolated inside a JS string literal and isn't visibly encoded inline or where it was bound (sanitized,escaped,json, ...). Medium when the value is named like input, else low.- Secret-named values or keys written to
UserDefaults(set(_:forKey:),@AppStorage("authToken")), or copied toUIPasteboard.general. NSXPCListenerservices (entry points), and ashouldAcceptNewConnectionthat returnstruewithout checking the peer: no audit token / PID / code-signing requirement, no validate/verify helper, and the connection isn't passed to any call. High when aNSXPCListener(machServiceName:)is registered in the same file or target (top-level directory); otherwise low, since a bundled XPC service or anonymous listener is reachable only by its parent app or an endpoint holder.NSClassFromString/NSSelectorFromString/dlopenon a string built at the call site.- URL-scheme and universal-link handlers as entry points.
-
Dependency SBOM — parses
Package.resolved(formats v1, v2, and v3, including the copy Xcode stashes under*.xcworkspace/xcshareddata/swiftpm/) into the scan's dependency inventory, marking direct vs. transitive by cross-referencing thePackage.swiftmanifest. SwiftPM pins carry their repository URL, which--cvematches against OSV'sSwiftURLecosystem. CocoaPodsPodfile.lockpods are inventoried (cocoapods; direct when listed underDEPENDENCIES:, subspecs folded into their pod); OSV has no CocoaPods database, so they aren't CVE-matched. CarthageCartfile.resolvedpins are inventoried ascarthage(direct when theCartfilelists them, a leadingvdropped from tag versions) with the repository URL, so--cvematches them against OSV'sSwiftURLecosystem like SwiftPM pins. -
Framework hints — flags server-side frameworks (Vapor, Hummingbird, Kitura, Perfect) when declared in the manifest.
-
Entrypoints —
main.swiftand@main. -
Objective-C / Objective-C++ (AttackMap#190) — a second analyzer in this package,
objc(opt-in:-m objc), for.m/.mmfiles that look like Objective-C (not MATLAB). It runs the same project-file checks (Info.plist, entitlements, xcconfig, Cartfile.resolved) and, in code: URL-scheme / universal-link / XPC entry points,evaluateJavaScript:with astringWithFormat:%@inside a JS string literal, secret-named values or keys inNSUserDefaultsor on the pasteboard, XPC listeners that returnYESwithout checking the peer,NSClassFromString/NSSelectorFromString/dlopenon built strings, and the native weaknesses shared with the C/C++ plugins: a non-literal, non-localized format with no arguments ([NSString stringWithFormat:msg],NSLog(msg)) asformat_string, and/bin/sh -cwith a built command orsystem()/popen()on a non-literal asnative_command_exec.NSFileManager/NSURLfile sinks aren't reported (no Objective-C taint pass yet). When both analyzers run, core's merge drops the duplicate project-file signals.
Roadmap
- Taint for Swift/Objective-C sources (URL-scheme parameters to WKWebView / file sinks).
Part of the Swift analyzer epic.
Development
pip install -e ".[dev]"
pytest -q
License
MIT. Copyright (c) 2026 Matthew Davis and AttackMap Contributors.
Metadata
Release files for attackmap-analyzer-swift 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| attackmap_analyzer_swift-0.2.1.tar.gz | 61.0 kB | With provenance | Details for attackmap_analyzer_swift-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| attackmap_analyzer_swift-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for attackmap_analyzer_swift-0.2.1-py3-none-any.whl |
Total release size: 107.4 kB
Release files / attackmap_analyzer_swift-0.2.1.tar.gz
| Download URL | attackmap_analyzer_swift-0.2.1.tar.gz |
|---|---|
| Size | 61.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e945f89b59c4658304f85e549542ecfc74bd07914084e7c9d545e8e012f5bb8
|
|
BLAKE2b-256 checksum How to use checksums |
2c7784725efb54bafa8b68d2652f6f83f7628a72dc2986e17b74b103c3dd3ba7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / attackmap_analyzer_swift-0.2.1-py3-none-any.whl
| Download URL | attackmap_analyzer_swift-0.2.1-py3-none-any.whl |
|---|---|
| Size | 46.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1811ff9a07502deb36fbc10059ba6700b4a743b3bd78666a7a35204dbc24a864
|
|
BLAKE2b-256 checksum How to use checksums |
da57fe8ea2860cb9d2449ed57dba394549ee9d34b48c170015d9f3459da77d6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for attackmap-analyzer-swift 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for attackmap_analyzer_swift-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.