Skip to content

Commit f0f8ebc

Browse files
Merge pull request #5 from devopselvis/copilot/fix-2345d43d-6d10-4934-8286-07f62d5ac32b
Add vulnerable dependency with multiple paths in dependency graph
2 parents 3f73f48 + 248b685 commit f0f8ebc

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

DEPENDENCY_ANALYSIS.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Dependency Analysis
2+
3+
## Vulnerable Dependency in Multiple Paths
4+
5+
This project demonstrates a vulnerable dependency (`commons-collections:3.2.1`) appearing in multiple paths in the dependency graph.
6+
7+
### The Vulnerable Package
8+
9+
**Package**: `commons-collections:3.2.1`
10+
11+
**Known Vulnerabilities**:
12+
- CVE-2015-7501: Apache Commons Collections InvokerTransformer class allows remote attackers to execute arbitrary Java code via crafted serialized objects through unsafe deserialization
13+
- This vulnerability affects commons-collections versions 3.0 through 3.2.1
14+
15+
### Dependency Paths
16+
17+
The `commons-collections:3.2.1` package appears in the following paths in the dependency graph:
18+
19+
1. **Direct Dependency**
20+
```
21+
vulnerable-app
22+
└── commons-collections:3.2.1
23+
```
24+
25+
2. **Transitive Dependency via commons-beanutils**
26+
```
27+
vulnerable-app
28+
└── commons-beanutils:1.9.2
29+
└── commons-collections:3.2.1
30+
```
31+
32+
3. **Transitive Dependency via commons-digester**
33+
```
34+
vulnerable-app
35+
└── commons-digester:2.1
36+
└── commons-beanutils:1.8.3
37+
└── commons-collections:3.2.1
38+
```
39+
40+
### Verification
41+
42+
To verify that the package appears in multiple paths, run:
43+
44+
```bash
45+
mvn dependency:tree -Dverbose
46+
```
47+
48+
Look for lines showing `commons-collections` with annotations like "omitted for duplicate" which indicates it's being pulled in through multiple paths.
49+
50+
Example output:
51+
```
52+
[INFO] +- commons-collections:commons-collections:jar:3.2.1:compile
53+
[INFO] +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
54+
[INFO] | \- (commons-collections:commons-collections:jar:3.2.1:compile - omitted for duplicate)
55+
[INFO] +- commons-digester:commons-digester:jar:2.1:compile
56+
[INFO] | +- (commons-beanutils:commons-beanutils:jar:1.8.3:compile - omitted for conflict with 1.9.2)
57+
[INFO] | \- (commons-collections:commons-collections:jar:3.2.1:compile - would be included)
58+
```
59+
60+
The key indicators are:
61+
- "omitted for duplicate" means the same dependency version is already included from another path
62+
- "omitted for conflict" means a different version of the same dependency is already included from another path
63+
- Both indicate multiple paths to the same or similar dependencies
64+
65+
### Why This Matters
66+
67+
In real-world scenarios, vulnerable dependencies often appear in multiple paths through the dependency graph. This makes them:
68+
- More challenging to identify
69+
- Harder to remediate (requires updating multiple parent dependencies)
70+
- More likely to be overlooked by basic security scanning
71+
72+
This repository intentionally includes this pattern to demonstrate how dependency scanning tools like GitHub's Dependabot and CodeQL can detect such vulnerabilities across the entire dependency graph.
73+
74+
## Viewing the Full Dependency Graph
75+
76+
To see the complete dependency tree:
77+
78+
```bash
79+
# Standard view (duplicates are omitted)
80+
mvn dependency:tree
81+
82+
# Verbose view (shows all paths including duplicates)
83+
mvn dependency:tree -Dverbose
84+
85+
# Filter to see only commons-related dependencies
86+
mvn dependency:tree -Dverbose | grep commons
87+
```
88+
89+
## Security Recommendations
90+
91+
⚠️ **For educational purposes only**
92+
93+
In a production environment, you would:
94+
1. Upgrade to a patched version of the vulnerable library
95+
2. If no patch exists, find alternative libraries
96+
3. Use dependency scanning tools to continuously monitor for vulnerabilities
97+
4. Implement Software Composition Analysis (SCA) in your CI/CD pipeline

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ This application contains the following types of security vulnerabilities:
2424
4. **LDAP Injection** - Unescaped user input in LDAP filters
2525
5. **Weak Cryptography** - Use of MD5 and weak random number generation
2626
6. **Hard-coded Secrets** - Embedded credentials and encryption keys
27+
7. **Vulnerable Dependencies** - Uses `commons-collections:3.2.1` which has known deserialization vulnerabilities (CVE-2015-7501). This dependency appears in multiple paths in the dependency graph:
28+
- As a direct dependency
29+
- As a transitive dependency through `commons-beanutils:1.9.2`
30+
- As a transitive dependency through `commons-digester:2.1``commons-beanutils:1.8.3`
2731

2832
## CodeQL Analysis
2933

@@ -45,8 +49,24 @@ mvn test
4549

4650
# Run the application (demonstrates vulnerabilities)
4751
mvn exec:java -Dexec.mainClass="com.example.app.VulnerableApplication"
52+
53+
# View dependency tree to see multiple paths to commons-collections
54+
mvn dependency:tree -Dverbose
4855
```
4956

57+
### Viewing Multiple Dependency Paths
58+
59+
To see how `commons-collections:3.2.1` appears in multiple paths in the dependency graph, run:
60+
61+
```bash
62+
mvn dependency:tree -Dverbose | grep -E "commons-collections|commons-beanutils|commons-digester"
63+
```
64+
65+
Expected output shows `commons-collections:3.2.1` appearing as:
66+
- A direct dependency
67+
- A transitive dependency through `commons-beanutils` (marked as "omitted for duplicate")
68+
- A transitive dependency through `commons-digester``commons-beanutils`
69+
5070
## Warning
5171

5272
⚠️ **This application contains intentional security vulnerabilities and should never be deployed in a production environment.** It is designed solely for educational purposes and CodeQL demonstration.

pom.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,34 @@
4141
<artifactId>commons-lang3</artifactId>
4242
<version>3.12.0</version>
4343
</dependency>
44+
45+
<!-- Vulnerable dependency (commons-collections 3.2.1) - direct dependency -->
46+
<dependency>
47+
<groupId>commons-collections</groupId>
48+
<artifactId>commons-collections</artifactId>
49+
<version>3.2.1</version>
50+
</dependency>
51+
52+
<!-- commons-beanutils also depends on commons-collections 3.2.1 - creates multiple paths -->
53+
<dependency>
54+
<groupId>commons-beanutils</groupId>
55+
<artifactId>commons-beanutils</artifactId>
56+
<version>1.9.2</version>
57+
</dependency>
58+
59+
<!-- commons-configuration also depends on commons-collections - creates another path -->
60+
<dependency>
61+
<groupId>commons-configuration</groupId>
62+
<artifactId>commons-configuration</artifactId>
63+
<version>1.10</version>
64+
</dependency>
65+
66+
<!-- commons-digester also depends on commons-collections - creates another path -->
67+
<dependency>
68+
<groupId>commons-digester</groupId>
69+
<artifactId>commons-digester</artifactId>
70+
<version>2.1</version>
71+
</dependency>
4472

4573
<!-- Database connectivity for SQL injection demos -->
4674
<dependency>

0 commit comments

Comments
 (0)