T09 · Insecure Skill Coding Practices
- Location
templates/authenticated-session.sh:27- Finding
Authentication State Is Stored Without Enforced File Protection and Is Not Covered by the Recommended Ignore Pattern
- Content
View full analysis
Vulnerability Details
File Location:
templates/authenticated-session.sh:27, 98-99
Related Locations:references/authentication.md:51, 179-181;references/session-management.md:41-50, 181-185
Vulnerability Type: Plaintext sensitive state storage and incomplete repository exclusion
Risk Level: MediumVulnerable Code
From
templates/authenticated-session.sh:bash STATE_FILE="${2:-./auth-state.json}"bash # Save state for future runs # echo "Saving state to $STATE_FILE" # agent-browser state save "$STATE_FILE"From
references/authentication.md:bash # Save authenticated state agent-browser state save ./auth-state.jsonbash 1. **Never commit state files** - They contain session tokens ```bash echo "*.auth-state.json" >> .gitignoretext From `references/session-management.md`: ```bash ### State File Contents ```json { "cookies": [...], "localStorage": {...}, "sessionStorage": {...}, "origins": [...] }text ```bash # Don't commit state files (contain auth tokens!) echo "*.auth-state.json" >> .gitignore # Delete after use rm /tmp/auth-state.jsonTechnical Analysis
The authenticated-session template defaults to writing reusable browser state to
./auth-state.json. The project documentation confirms that state files contain cookies and browser storage and may therefore contain bearer session tokens, refresh tokens, and other authentication material.The workflow does not set a restrictive process umask, create a private storage directory, or enforce mode
0600on the resulting file. Its effective permissions consequently depend on the caller's environment and the behavior ofagent-browser.The recommended Git exclusion rule is also incomplete. The pattern
*.auth-state.jsondoes not match the default filenameauth-state.json. It also does not cover other documented names such asoauth-state.jsonand2fa-state.json. A user who follows the documented guidance ...[truncated 1696 chars]- Remediation
View remediation
Remediation Suggestions
- Prefer the encrypted authentication vault already recommended by the project instead of exporting reusable browser state to project files.
- If state files are required, create them in a dedicated private directory and enforce restrictive permissions:
bash umask 077 STATE_DIR="${XDG_STATE_HOME:-$HOME/.local/state}/agent-browser" mkdir -p "$STATE_DIR" chmod 700 "$STATE_DIR" STATE_FILE="${2:-$STATE_DIR/auth-state.json}" agent-browser state save "$STATE_FILE" chmod 600 "$STATE_FILE"- Refuse to load state files that are accessible to group or other users, where supported by the operating system.
- Replace the incomplete ignore guidance with patterns covering every documented state filename, for example:
gitignore auth-state.json oauth-state.json 2fa-state.json *.auth-state.json *-state.json- Add an appropriate project-level
.gitignorerather than relying only on users to append patterns manually. - Avoid publishing state files as CI artifacts or retaining them in shared workspaces and backups. Delete them immediately after use when persistence is unnecessary.
- Use short-lived sessions, server-side revocation, token rotation, device binding, and mandatory reauthentication for sensitive actions to limit the effect of state-file disclosure.
- Document that state files must be treated as credentials and must never be logged, committed, attached to reports, or shared.
