gm-skill 2.0.2570 → 2.0.2572

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/AGENTS.md CHANGED
@@ -172,6 +172,16 @@ A task that reduces to read/investigate/report, or a change confined to files th
172
172
 
173
173
  **Bootstrap contract**: `ensureReady` inits wasm hook-free, sha256-rewrites stale installed SKILL.md, seeds per-project `CLAUDE.md`/`.gm/next-step.md`. Detail: the recall store (`recall: skill-initiated bootstrap contract`, `recall: SKILL.md auto-refresh`).
174
174
 
175
+ ## Supply-chain tell scanner
176
+
177
+ `scripts/scan-supply-chain-tells.mjs` scans any file tree for the injected-backdoor/AI-tell signature classes found in a real incident on a consumer project (freddie): an obfuscated C2 stager appended after a legitimate `export default` in a build config, delivered via a compromised automated release commit that also bumped a dependency and dropped `.env` from `.gitignore`. Run it: `node scripts/scan-supply-chain-tells.mjs <path...>` (defaults to cwd). Exit 0 = clean, 1 = findings, 2 = scan error.
178
+
179
+ Detection classes: exact-match known-incident strings (campaign tag, hardcoded C2-lookup address, custom payload-smuggling header), structural patterns (blockchain-RPC-derived C2 address resolution, IP-from-bytes decode, detached+hidden-stdio child-process spawn, `eval()` fed by a network response, XOR-decode loops, `require`/`module` stashed onto `global`, a dense minified tail line appended to an otherwise normal readable file, `\uXXXX`-escaped ASCII used to defeat plaintext grep, multiple public RPC endpoints raced with `Promise.any` for C2 resilience), and Unicode confusables/invisible characters (zero-width spaces/joiners, bidi override characters — the Trojan Source class — soft hyphens, and common Cyrillic homoglyphs for Latin letters).
180
+
181
+ **Dispatch this scan at EMIT (before any live witness) and again at DECIDE's adversarial corner-case sweep, on every file the diff touches** — alongside the existing empty/overflow/injection/resource-exhaustion sweep classes, not instead of them. A `security` toolset dependency bump, an automated release commit, or any file with unexpectedly dense/obfuscated content are the highest-suspicion triggers for an out-of-band run against the full tree, not just the diff. A finding routes like any other DECIDE discovery: confirmed-malicious content is a `transition to=EMIT` fix (remove and re-witness), never a silent ignore or a "looks fine" without running the scan.
182
+
183
+ This is a heuristic signature scanner, not a guarantee — it catches the specific technique classes seen in the confirmed incident and known-adjacent variants; it does not replace `npm audit`, dependency pinning review, or reading an unfamiliar dependency's actual source before trusting an automated bump.
184
+
175
185
  ## Cascade pipeline
176
186
 
177
187
  Push to any rs-* sibling -> `cascade.yml` -> rs-plugkit `release.yml` -> single `plugkit.wasm` (npm `plugkit-wasm` + `plugkit-bin` Releases) -> best-effort gm-metadata-sync commit -> `publish.yml` ships gm-skill+gm-plugkit+SKILL.md mirror. Step sequence + PUBLISHER_TOKEN: the recall store (`recall: cascade pipeline`).
@@ -1 +1 @@
1
- 5f709275d5f02c32474faaaffc304b60ea91cad1cdfae56ec4f4da2397461e5b plugkit-slim.wasm
1
+ 02cae93317f0d965fd004304a2cdf74dd298765cd370061c70a55b9eef41689c plugkit-slim.wasm
@@ -1 +1 @@
1
- 0.1.1210
1
+ 0.1.1211
@@ -1 +1 @@
1
- 4f40350f6377c5065f918165378c7574d3871661d622b4f1f891654c868be705 plugkit.wasm
1
+ 165bfc856da6a5d3aa0775cc28f4e76cb67a86e68f89a63b341c8b198c670d45 plugkit.wasm
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.2570",
3
+ "version": "2.0.2572",
4
4
  "description": "Bootstrap and daemon-spawn tool for gm plugkit binary. Downloads the correct platform wasm, verifies SHA256, and launches agentplug-runner (the native wasm host) as the spool watcher daemon.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1 +1 @@
1
- 5f709275d5f02c32474faaaffc304b60ea91cad1cdfae56ec4f4da2397461e5b plugkit-slim.wasm
1
+ 02cae93317f0d965fd004304a2cdf74dd298765cd370061c70a55b9eef41689c plugkit-slim.wasm
@@ -1 +1 @@
1
- 0.1.1210
1
+ 0.1.1211
package/gm.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.2570",
3
+ "version": "2.0.2572",
4
4
  "description": "Spool-dispatch orchestration engine with unified state machine, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -17,5 +17,5 @@
17
17
  "publishConfig": {
18
18
  "access": "public"
19
19
  },
20
- "plugkitVersion": "0.1.1210"
20
+ "plugkitVersion": "0.1.1211"
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-skill",
3
- "version": "2.0.2570",
3
+ "version": "2.0.2572",
4
4
  "description": "Canonical universal harness — AI-native software engineering via skill-driven orchestration; bootstraps plugkit for task execution and session isolation. Install in any AI coding agent host.",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -0,0 +1,257 @@
1
+ #!/usr/bin/env node
2
+ // Scans files for supply-chain-backdoor and AI-injection "tells" -- signatures
3
+ // found live in a real incident (an obfuscated C2 stager appended to
4
+ // vite.browser.config.js, delivered via a compromised automated release
5
+ // commit that also bumped a dependency and dropped .env from .gitignore).
6
+ //
7
+ // Run standalone: node scripts/scan-supply-chain-tells.mjs [path...]
8
+ // Exit code 0 = clean, 1 = findings, 2 = scan error.
9
+ //
10
+ // Designed to be invoked from any project (not just this one) -- pass the
11
+ // target repo root(s) as argv, or it scans cwd.
12
+
13
+ import fs from 'node:fs'
14
+ import path from 'node:path'
15
+ import process from 'node:process'
16
+
17
+ const SKIP_DIRS = new Set([
18
+ 'node_modules', '.git', 'dist', 'build', '.next', 'vendor', '.cache',
19
+ '.svelte-kit', '.nuxt', '.output', '.turbo', 'out', 'coverage', '.parcel-cache',
20
+ ])
21
+ // Code files only. JSON/YAML/MD routinely carry legitimate non-Latin natural-
22
+ // language text (Cyrillic, Greek, CJK, etc.) which is indistinguishable from a
23
+ // homoglyph attack by codepoint alone -- the Unicode-confusable check below is
24
+ // only meaningful applied to CODE, where an identifier/URL is expected to be
25
+ // plain ASCII and non-ASCII inside one is a genuine anomaly, not content.
26
+ const CODE_EXT = new Set(['.js', '.mjs', '.cjs', '.ts', '.tsx', '.jsx', '.sh', '.ps1', '.py'])
27
+ // Broader set for the exact-string / pattern checks, which key on code shapes
28
+ // (require calls, eval, spawn) that can legitimately only appear in code or
29
+ // config, not prose -- config/build files are still worth the exact-string and
30
+ // structural-pattern passes, just not the Unicode-confusable pass.
31
+ const TEXT_EXT = new Set([...CODE_EXT, '.json', '.yml', '.yaml', '.md'])
32
+
33
+ // ---- Exact-match signatures from the confirmed incident ----------------
34
+ const EXACT_STRINGS = [
35
+ { sig: 'A9-2057', why: 'campaign/version tag literal seen in a live C2 stager' },
36
+ { sig: '0xa322E5f3D311D3080e6f0121063e9aDC2490Ef1a', why: 'hardcoded Ethereum address used as a blockchain-based C2 config lookup key' },
37
+ { sig: 'eth.blockscout.com/api', why: 'block-explorer API used as a C2-resolution fallback' },
38
+ { sig: 'x-payload-b64', why: 'custom HTTP header used to smuggle a staged payload' },
39
+ ]
40
+
41
+ // ---- Structural / behavioral patterns (regex) ---------------------------
42
+ const PATTERNS = [
43
+ {
44
+ name: 'blockchain-derived-c2-lookup',
45
+ re: /eth_getBlockByNumber|eth_getTransactionCount|eth_blockNumber/,
46
+ why: 'blockchain RPC calls used to derive a C2 address/config are a known dead-drop technique — legitimate web3 code should be an isolated, obviously-named module, not appended to an unrelated build config',
47
+ },
48
+ {
49
+ name: 'ip-from-bytes-decode',
50
+ re: /\[0\]\s*\+\s*['"]\.['"]\s*\+\s*\w+\[1\]\s*\+\s*['"]\.['"]\s*\+\s*\w+\[2\]/,
51
+ why: 'byte-array-to-dotted-IP decode shape, commonly used to hide a C2 address inside binary data (a tx field, an image, etc.)',
52
+ },
53
+ {
54
+ name: 'detached-hidden-spawn',
55
+ re: /spawn\s*\(\s*['"]node['"][\s\S]{0,120}detached\s*:\s*true[\s\S]{0,120}stdio\s*:\s*['"]ignore['"]/,
56
+ why: 'detached + stdio:ignore + unref() child process launch — runs code that outlives and is invisible to the parent process',
57
+ },
58
+ {
59
+ name: 'detached-hidden-spawn-loose',
60
+ re: /detached\s*:\s*true[\s\S]{0,60}(stdio\s*:\s*['"]ignore['"]|windowsHide\s*:\s*true)/,
61
+ why: 'detached background process with hidden stdio/window — legitimate daemonization exists but is rare in application/build code and should be named and commented',
62
+ },
63
+ {
64
+ name: 'eval-of-network-response',
65
+ re: /eval\s*\(\s*[\w.]*\+?\s*(await\s+)?\w*(fetch|http|https|response|body|payload|res)\w*/i,
66
+ why: 'eval() fed directly by network response content — remote code execution primitive',
67
+ },
68
+ {
69
+ name: 'xor-decode-helper',
70
+ re: /charCodeAt\(\w+\s*%\s*\w+\.length\)/,
71
+ why: 'per-byte XOR-against-key loop, the standard shape for decoding an obfuscated payload at runtime',
72
+ },
73
+ {
74
+ name: 'global-require-module-stash',
75
+ re: /global\.\w+\s*=\s*require\s*;\s*typeof\s+module\s*===\s*['"]object['"]/,
76
+ why: 'stashing require/module onto global — used so eval()-ed code can access them outside its lexical scope',
77
+ },
78
+ {
79
+ name: 'minified-tail-after-normal-code',
80
+ re: /\n[a-z]\.[a-z]\([a-z],[a-z],[a-z]\)/,
81
+ why: 'single-letter-identifier minified code appearing after normally-formatted source — mixing styles in one file is a strong injection tell',
82
+ weak: true,
83
+ },
84
+ {
85
+ name: 'promise-any-rpc-race',
86
+ re: /Promise\.any\(\s*\[?\s*['"]https?:\/\/[^,\]]+,\s*['"]https?:\/\//,
87
+ why: 'racing multiple public RPC/API endpoints for resilience — common in C2 code designed to survive one endpoint being blocked',
88
+ },
89
+ ]
90
+
91
+ // ---- Unicode confusables / invisible-character tells ---------------------
92
+ // Each entry: a *visible-as-ASCII-but-isn't* or fully invisible codepoint.
93
+ const SUSPICIOUS_UNICODE = [
94
+ { cp: 0x200b, name: 'ZERO WIDTH SPACE' },
95
+ { cp: 0x200c, name: 'ZERO WIDTH NON-JOINER' },
96
+ { cp: 0x200d, name: 'ZERO WIDTH JOINER' },
97
+ { cp: 0x200e, name: 'LEFT-TO-RIGHT MARK' },
98
+ { cp: 0x200f, name: 'RIGHT-TO-LEFT MARK' },
99
+ { cp: 0x202a, name: 'LEFT-TO-RIGHT EMBEDDING' },
100
+ { cp: 0x202b, name: 'RIGHT-TO-LEFT EMBEDDING' },
101
+ { cp: 0x202c, name: 'POP DIRECTIONAL FORMATTING' },
102
+ { cp: 0x202d, name: 'LEFT-TO-RIGHT OVERRIDE' },
103
+ { cp: 0x202e, name: 'RIGHT-TO-LEFT OVERRIDE (Trojan Source bidi attack)' },
104
+ { cp: 0x2060, name: 'WORD JOINER' },
105
+ { cp: 0x2066, name: 'LEFT-TO-RIGHT ISOLATE' },
106
+ { cp: 0x2067, name: 'RIGHT-TO-LEFT ISOLATE' },
107
+ { cp: 0x2068, name: 'FIRST STRONG ISOLATE' },
108
+ { cp: 0x2069, name: 'POP DIRECTIONAL ISOLATE' },
109
+ { cp: 0xfeff, name: 'ZERO WIDTH NO-BREAK SPACE / BOM (mid-file)' },
110
+ { cp: 0x00ad, name: 'SOFT HYPHEN' },
111
+ // Common homoglyphs used to disguise identifiers/URLs (Cyrillic look-alikes)
112
+ { cp: 0x0410, name: 'CYRILLIC CAPITAL А (looks like Latin A)' },
113
+ { cp: 0x0430, name: 'CYRILLIC SMALL а (looks like Latin a)' },
114
+ { cp: 0x0415, name: 'CYRILLIC CAPITAL Е (looks like Latin E)' },
115
+ { cp: 0x0435, name: 'CYRILLIC SMALL е (looks like Latin e)' },
116
+ { cp: 0x041e, name: 'CYRILLIC CAPITAL О (looks like Latin O)' },
117
+ { cp: 0x043e, name: 'CYRILLIC SMALL о (looks like Latin o)' },
118
+ { cp: 0x0420, name: 'CYRILLIC CAPITAL Р (looks like Latin P)' },
119
+ { cp: 0x0440, name: 'CYRILLIC SMALL р (looks like Latin p)' },
120
+ { cp: 0x0421, name: 'CYRILLIC CAPITAL С (looks like Latin C)' },
121
+ { cp: 0x0441, name: 'CYRILLIC SMALL с (looks like Latin c)' },
122
+ ]
123
+
124
+ // A file whose non-ASCII payload is almost entirely \uXXXX-style JS escape
125
+ // sequences decoding to plain ASCII is itself a tell (deliberate obfuscation
126
+ // to defeat plain-string grep, seen in the confirmed incident's http/https/
127
+ // url/child_process require() calls).
128
+ const ESCAPED_ASCII_RUN = /(\\u00[2-7][0-9a-fA-F]){6,}/
129
+
130
+ function walk(dir, out) {
131
+ let entries
132
+ try {
133
+ entries = fs.readdirSync(dir, { withFileTypes: true })
134
+ } catch {
135
+ return
136
+ }
137
+ for (const e of entries) {
138
+ if (SKIP_DIRS.has(e.name)) continue
139
+ const p = path.join(dir, e.name)
140
+ if (e.isDirectory()) {
141
+ walk(p, out)
142
+ } else if (e.isFile() && TEXT_EXT.has(path.extname(e.name))) {
143
+ out.push(p)
144
+ }
145
+ }
146
+ }
147
+
148
+ function scanFile(filePath) {
149
+ let text
150
+ try {
151
+ text = fs.readFileSync(filePath, 'utf8')
152
+ } catch {
153
+ return []
154
+ }
155
+ const findings = []
156
+
157
+ for (const { sig, why } of EXACT_STRINGS) {
158
+ if (text.includes(sig)) {
159
+ findings.push({ filePath, kind: 'exact-string', sig, why })
160
+ }
161
+ }
162
+
163
+ for (const { name, re, why, weak } of PATTERNS) {
164
+ const m = text.match(re)
165
+ if (m) {
166
+ const line = text.slice(0, m.index).split('\n').length
167
+ findings.push({ filePath, kind: weak ? 'pattern-weak' : 'pattern', name, why, line })
168
+ }
169
+ }
170
+
171
+ const lines = text.split('\n')
172
+ const nonBlank = lines.filter(l => l.trim().length > 0)
173
+ if (nonBlank.length >= 5) {
174
+ const lens = nonBlank.map(l => l.length)
175
+ const avgLen = lens.reduce((a, b) => a + b, 0) / lens.length
176
+ const lastLen = lens[lens.length - 1]
177
+ const looksMinified = /[;,]\s*[a-zA-Z_$][\w$]*\s*=/.test(nonBlank[nonBlank.length - 1]) &&
178
+ /\b(function|=>|require\(|const |let |var )\b/.test(nonBlank[nonBlank.length - 1])
179
+ if (lastLen > 2000 && lastLen > avgLen * 20 && looksMinified) {
180
+ findings.push({
181
+ filePath,
182
+ kind: 'pattern',
183
+ name: 'dense-minified-tail-line',
184
+ line: nonBlank.length,
185
+ why: `final non-blank line is ${lastLen} chars (${Math.round(lastLen / avgLen)}x the file's average line length) and looks like minified code — this is the exact shape of a payload appended to the end of an otherwise normal, readable file`,
186
+ })
187
+ }
188
+ }
189
+
190
+ if (ESCAPED_ASCII_RUN.test(text)) {
191
+ findings.push({
192
+ filePath,
193
+ kind: 'pattern',
194
+ name: 'escaped-ascii-obfuscation',
195
+ why: '6+ consecutive \\uXXXX escapes decoding to plain ASCII — deliberate string obfuscation to defeat plaintext grep (e.g. \\u0068\\u0074\\u0074\\u0070 = "http")',
196
+ })
197
+ }
198
+
199
+ if (CODE_EXT.has(path.extname(filePath))) {
200
+ // De-duplicate per (codepoint, line): a run of several confusables on one
201
+ // line (a whole disguised word) is one finding, not one per character.
202
+ const seen = new Set()
203
+ for (let i = 0; i < text.length; i++) {
204
+ const cp = text.codePointAt(i)
205
+ const hit = SUSPICIOUS_UNICODE.find(u => u.cp === cp)
206
+ if (hit) {
207
+ const line = text.slice(0, i).split('\n').length
208
+ const key = cp + ':' + line
209
+ if (seen.has(key)) continue
210
+ seen.add(key)
211
+ findings.push({
212
+ filePath,
213
+ kind: 'unicode',
214
+ name: hit.name,
215
+ codepoint: '0x' + cp.toString(16),
216
+ line,
217
+ why: 'invisible or confusable Unicode codepoint inside a code file — used to hide code from visual review or disguise an identifier/URL as something else',
218
+ })
219
+ }
220
+ }
221
+ }
222
+
223
+ return findings
224
+ }
225
+
226
+ function main() {
227
+ const targets = process.argv.slice(2)
228
+ const roots = targets.length ? targets : [process.cwd()]
229
+ const files = []
230
+ for (const root of roots) {
231
+ const stat = fs.existsSync(root) ? fs.statSync(root) : null
232
+ if (!stat) continue
233
+ if (stat.isDirectory()) walk(root, files)
234
+ else files.push(root)
235
+ }
236
+
237
+ const allFindings = []
238
+ for (const f of files) {
239
+ allFindings.push(...scanFile(f))
240
+ }
241
+
242
+ if (!allFindings.length) {
243
+ console.log(`scan-supply-chain-tells: clean (${files.length} files scanned)`)
244
+ process.exit(0)
245
+ }
246
+
247
+ console.log(`scan-supply-chain-tells: ${allFindings.length} finding(s) across ${new Set(allFindings.map(f => f.filePath)).size} file(s)\n`)
248
+ for (const f of allFindings) {
249
+ const loc = f.line ? `:${f.line}` : ''
250
+ const label = f.sig || f.name
251
+ console.log(`[${f.kind}] ${f.filePath}${loc} — ${label}`)
252
+ console.log(` ${f.why}`)
253
+ }
254
+ process.exit(1)
255
+ }
256
+
257
+ main()