Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to this project are documented here, following

### Added

- **SKILL-SEC-007**: flag references to bash, zsh, and PowerShell ConsoleHost history files.
- **SKILL-OBF-004**: flag PowerShell `-EncodedCommand` / `-enc` and `xxd -r` output piped into a shell.
- **SKILL-INJ-010**: flag prose that fetches remote instructions and tells the agent to follow them.
- **SKILL-SUP-003**: flag code that fetches scripts or packages over plaintext `http://`.
Expand Down
5 changes: 5 additions & 0 deletions src/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ export const RULES = [
remediation: "Reading the keychain, keyring, or secret-tool exposes stored credentials.",
pattern: /(security\s+find-generic-password|gnome-keyring|\bsecret-tool\b|keychain)/gi },

{ id: "SKILL-SEC-007", severity: "high", category: "secret-access", appliesTo: "code",
title: "Reads shell-history files",
remediation: "Shell history can contain commands with credentials and other secrets. Do not read it from a skill.",
pattern: /(\.bash_history\b|\.zsh_history\b|ConsoleHost_history(?:\.txt)?\b)/gi },

// ---- Network exfiltration ----
{ id: "SKILL-NET-001", severity: "high", category: "exfiltration", appliesTo: "code",
title: "Uploads a local file over the network",
Expand Down
26 changes: 26 additions & 0 deletions test/sec-007-shell-history.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { scanText } from "../src/scan.js";

test("SKILL-SEC-007 flags shell-history file references", () => {
for (const [source, file] of [
["cat ~/.bash_history\n", "setup.sh"],
["tail -n 50 ~/.zsh_history\n", "setup.sh"],
["Get-Content $env:APPDATA\\Microsoft\\Windows\\PowerShell\\PSReadLine\\ConsoleHost_history.txt\n", "setup.ps1"],
]) {
const findings = scanText(source, file, null).filter((f) => f.rule === "SKILL-SEC-007");
assert.equal(findings.length, 1, `${file}: ${source}`);
assert.equal(findings[0].severity, "high");
}
});

test("SKILL-SEC-007 ignores ordinary history-related text", () => {
for (const source of [
"history | tail -20\n",
"echo 'keep a changelog of command history'\n",
"const history = []\n",
]) {
const findings = scanText(source, "setup.sh", null).filter((f) => f.rule === "SKILL-SEC-007");
assert.equal(findings.length, 0, source);
}
});
Loading