T01 · Skill Instruction Hijacking
- Location
agents-section.md:10- Finding
Delegated Agent Runs with Permission Enforcement Disabled
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill openly sets up Claude Code automation, but it teaches agents to expose local OAuth tokens and bypass normal permission checks.
Review before installing. Do not use this skill as written on a machine with real Claude credentials or sensitive repositories unless you remove raw token extraction, remove shell-profile token loading, avoid --dangerously-skip-permissions, and run delegated agents in a constrained environment with explicit approval for sensitive actions.
agents-section.md:10Delegated Agent Runs with Permission Enforcement Disabled
SKILL.md:68OAuth Token Is Explicitly Extracted into Commands and Tool Output
agents-section.md:33Task Text Can Escape Shell Quoting and Execute Arbitrary Commands
setup.sh:14Setup Installs an Unpinned Package Globally
The skill repeatedly instructs agents to extract a long-lived OAuth token from a local credentials file and reuse it in commands. That normalizes credential harvesting from agent-accessible storage and creates a path for unauthorized token exposure, replay, or leakage into logs, subprocesses, shell history, or downstream tools.
Disclosing the exact location of a long-lived credential file lowers the barrier for any downstream agent or user to target that secret store. In this skill, the disclosure is paired with repeated extraction instructions, making it more dangerous than a neutral reference.
Claude Code stores its OAuth token in:
~/.claude/.credentials.json
This line instructs direct reading of ~/.claude/.credentials.json to extract an access token. Accessing agent config directories for secrets is dangerous because it turns local credential stores into consumable input for automation, increasing risk of exfiltration and misuse.
Option 1: Extract from credentials file (RECOMMENDED)
# Extract the accessToken from credentials
cat ~/.claude/.credentials.json | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4
Option 2: Authenticate via browser (first-time setup)
This command directly accesses and extracts the access token from the credentials file. It is a true credential-access issue because it turns a stored secret into command output, enabling theft, replay, or accidental disclosure.
Option 1: Extract from credentials file (RECOMMENDED)
# Extract the accessToken from credentials
cat ~/.claude/.credentials.json | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4
Option 2: Authenticate via browser (first-time setup)
The documentation directs use of --dangerously-skip-permissions as the normal invocation pattern for Claude CLI calls. This bypasses interactive safeguards and approval boundaries, making it easier for automated tasks to perform sensitive actions without user review.
The examples repeatedly recommend --dangerously-skip-permissions but do not explain that it disables important safety and approval checks. Presenting unsafe flags as the standard workflow makes misuse more likely and lowers operator awareness of the security tradeoff.
This example routes tasks to an external model provider using an extracted OAuth token and an unsafe permissions-bypass flag. In combination, it can send user or repository data to an external service under unattended execution conditions, raising confidentiality and control risks.
# ✅ CORRECT - Token set explicitly
export CLAUDE_CODE_OAUTH_TOKEN="sk-ant-oat01-xxxxx..."
claude --print --dangerously-skip-permissions "your task"
# ❌ WRONG - Token not set, will fail in non-interactive mode
claude --print "your task"
Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.
claude --print --dangerously-skip-permissions "your task"
claude --print "your task"
### Automatic Token Extraction
This line persists automatic secret extraction in a shell profile, causing future sessions to load credentials implicitly. That expands the blast radius of any compromise and makes accidental leakage through child processes or environment inspection more likely.
Add to your shell profile for automatic token loading:
# Add to ~/.bashrc or ~/.zshrc
export CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json 2>/dev/null | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4)
This line installs persistent credential extraction into shell startup files, making secret loading automatic for all future shells. That increases long-term exposure and creates many opportunities for unintended propagation of the token.
Add to your shell profile for automatic token loading:
# Add to ~/.bashrc or ~/.zshrc
export CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json 2>/dev/null | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4)
This example embeds credential extraction directly into an exec command string for background execution. Secrets passed this way may be exposed to logs, process listings, task history, or other observability surfaces, while also normalizing unauthorized config-directory access.
exec({
command: "export CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4) && claude --print --dangerously-skip-permissions 'Task description'",
background: true,
yieldMs: 10000
})
This exec example accesses the credential file and exports the token inside a command string. Secret material handled this way may be exposed via logs, process inspection, or tool telemetry, making it a high-risk credential access pattern.
exec({
command: "export CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4) && claude --print --dangerously-skip-permissions 'Task description'",
background: true,
yieldMs: 10000
})
This instruction explicitly runs a command whose sole purpose is to extract and output the token from the credentials file. Printing or returning a secret is a direct exposure risk and is unnecessary in a secure automation design.
// First, extract token
exec({
command: "cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4"
})
// Then use in all subsequent calls
The instruction explicitly tells the agent to extract the token first as a separate command, meaning the credential may be returned in plain output. This is a direct and unnecessary exposure of authentication material.
// First, extract token
exec({
command: "cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4"
})
// Then use in all subsequent calls
This background-task pattern again reads the local credentials file and injects the token inline into a command. The combination of secret access plus unattended execution increases the chance of silent misuse and harder-to-detect credential exposure.
// Step 1: Extract token from credentials
// Step 2: Use in Claude Code call
exec({
command: "CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4) claude --print --dangerously-skip-permissions 'Task description'",
background: true,
yieldMs: 10000
})
This command accesses the credentials file to authenticate a background task. It combines direct credential access with unattended execution, increasing both exposure and abuse potential.
// Step 1: Extract token from credentials
// Step 2: Use in Claude Code call
exec({
command: "CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4) claude --print --dangerously-skip-permissions 'Task description'",
background: true,
yieldMs: 10000
})
Even for quick tasks, the skill mandates reading the credential store and using the token inline. Repeating this as a convenience pattern broadens routine secret handling and raises the likelihood of leakage in ordinary operations.
For simple tasks, use direct exec without tracking:
exec({
command: "CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4) claude --print --dangerously-skip-permissions 'Quick fix'",
timeout: 60
})
This quick-task example repeats the same credential-scraping pattern, which encourages widespread routine access to secrets. Frequent repetition of unsafe secret handling increases the probability of compromise.
For simple tasks, use direct exec without tracking:
exec({
command: "CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4) claude --print --dangerously-skip-permissions 'Quick fix'",
timeout: 60
})
Declaring the token location as a required part of agent guidance increases discoverability of a sensitive secret store. In this file's context, that contributes to a broader unsafe credential-handling workflow.
Token location: ~/.claude/.credentials.json
ALWAYS extract and use the token:
The AGENTS.md integration propagates credential-file access guidance into broader agent workflows. That institutionalizes sensitive config-directory access across projects, increasing systemic risk beyond this single skill.
ALWAYS extract and use the token:
CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4) claude --print --dangerously-skip-permissions 'task'
This line mandates extracting and using the token from the credentials file for all tasks. That is a direct credential-access instruction that can lead to exposure, misuse, and systemic secret handling by agents.
ALWAYS extract and use the token:
CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4) claude --print --dangerously-skip-permissions 'task'
Logging session IDs, labels, and task descriptions into a persistent markdown file can leak sensitive project context, user intent, or operational metadata. In an agent environment, such context can later be read by other tools or accidentally committed, broadening exposure.
All background sessions tracked in `memory/claude-code-sessions.md`.
**Before starting:** Check for running sessions
**After starting:** Log session ID + label
**On completion:** Update status column
### When User Asks Status
The workflow diagram includes extracting the token from ~/.claude/.credentials.json as a standard operational step. Embedding that into the canonical workflow normalizes secret access as expected behavior and increases the chance of abuse by downstream agents or operators.
↓
Agent reads memory/claude-code-sessions.md (check for conflicts)
↓
Agent extracts token: cat ~/.claude/.credentials.json | grep accessToken
↓
Agent starts: exec({ command: "CLAUDE_CODE_OAUTH_TOKEN=xxx claude ...", background: true })
↓
The workflow explicitly includes extracting the token from the credentials file as a standard step. That embeds secret access into routine operations and makes abuse more likely across repeated use.
↓
Agent reads memory/claude-code-sessions.md (check for conflicts)
↓
Agent extracts token: cat ~/.claude/.credentials.json | grep accessToken
↓
Agent starts: exec({ command: "CLAUDE_CODE_OAUTH_TOKEN=xxx claude ...", background: true })
↓
This checklist item tells users to verify token extractability from the credentials file, reinforcing that local secret access is acceptable. While less directly exploitive than command examples, it still trains operators and agents to treat credential scraping as routine.
- [ ] Claude Code CLI installed: `which claude`
- [ ] Authenticated: check `~/.claude/.credentials.json` exists
- [ ] Token extractable: `cat ~/.claude/.credentials.json | grep accessToken`
- [ ] Session file created: `memory/claude-code-sessions.md`
- [ ] AGENTS.md updated with session section
- [ ] APEX Stack added to project CLAUDE.md (if applicable)
No suspicious patterns detected.