Skip to content

Commit e28c251

Browse files
committed
Detect ZIP slip
1 parent d380605 commit e28c251

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

.config/pmd/java/ruleset.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,28 @@
316316
</properties>
317317
</rule>
318318

319+
<rule name="EnsureZipEntryNameIsSanitized"
320+
language="java"
321+
message="ZipEntry name should be sanitized"
322+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
323+
<description>
324+
ZipEntry name should be sanitized.
325+
Unsanitized names may contain '..' which can result in path traversal ("ZipSlip").
326+
327+
You can suppress this warning when you properly sanitized the name.
328+
</description>
329+
<priority>4</priority>
330+
<properties>
331+
<property name="xpath">
332+
<value>
333+
<![CDATA[
334+
//MethodCall[pmd-java:matchesSig('java.util.zip.ZipEntry#getName()') or pmd-java:matchesSig('org.apache.commons.compress.archivers.ArchiveEntry#getName()')]
335+
]]>
336+
</value>
337+
</property>
338+
</properties>
339+
</rule>
340+
319341
<rule name="JavaObjectSerializationIsUnsafe"
320342
language="java"
321343
message="Using Java Object (De-)Serialization is unsafe and has led to too many security vulnerabilities"

0 commit comments

Comments
 (0)