Aalexbit-codemod

java-zip-slip-mining

Mine archive extraction code that builds filesystem paths from archive entry names (zip slip) (javasecurity:S6096); read-only metrics for security review

miningmetricsjavasecurityvulnerabilityzip-slippath-traversalarchivecwe-22
Public
0 executions

Run locally

npx codemod java-zip-slip-mining

java-zip-slip-mining

Read-only mining codemod for SonarSource rule javasecurity:S6096Extracting archives should not lead to zip slip vulnerabilities.

It scans Java source and emits metrics only; it never modifies code (return null).
Findings are high-signal review candidates surfaced by AST pattern matching — they are
not proven vulnerabilities. A static mining pass cannot prove an end-to-end taint flow
from an untrusted source to the sink, so confirm data flow before remediating.

FieldValue
Rule keyjavasecurity:S6096
TypeVulnerability
SeverityBlocker
Primary CWECWE-22 (Path Traversal)
Tagscwe

What it detects

Archive extraction code that builds filesystem paths directly from archive entry names.

Sinks:

  • new File(..., entry.getName()) (and FileInputStream/FileOutputStream/RandomAccessFile/FileWriter)
  • Paths.get(... entry.getName()) / path.resolve(... entry.getName())

Emission rule: Emits when a path-construction sink contains a getName() call on an archive-entry-like receiver (entry/ze/zip/tar/archive).

Metric: java-zip-slip-mining

dimensionmeaning
ruleSonarSource rule key
cweprimary CWE identifier
severityalways blocker
sinkthe detected sink (method/constructor)
package_nameenclosing Java package
class_nameenclosing class/interface/enum/record
method_nameenclosing method/constructor (or <none>)
filefile path (relative to scan target)
line1-based line of the finding
arg_kindalways archive_entry

Security standards

  • CWE-20 (Improper Input Validation)
  • CWE-22 (Path Traversal)
  • OWASP ASVS 4.0: 5.1.3, 5.1.4, 12.3.4
  • OWASP Mobile Top 10 2024: M4
  • OWASP Top 10 2021: A1, A3
  • OWASP Top 10: A1, A5
  • PCI DSS 3.2: 6.5.1, 6.5.8
  • PCI DSS 4.0: 6.2.4
  • STIG ASD V5R3: V-222609

Run locally

bash

Part of the java-security-blocker-mining suite covering 19 blocker-severity
Java vulnerability rules. Each codemod is read-only and emits a single named metric.

Ready to contribute?

Build your own codemod and share it with the community.