Local worker / on-device agent
Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.
For agents
- A local worker acts on a machine without a person watching each step. Typical class: M, or L when it touches sensitive data or many machines.
- Rule 1: run with least privilege inside a sandbox; paths cannot escape the allowed folder.
- Rule 2: commands come from an allow list, arguments as a list, with time and output limits.
- Rule 3: destructive actions need human approval and everything is logged.
Which class?
- S: a personal helper on your own machine with no sensitive data.
- M: it handles personal data, secrets or an API key, or acts for other users.
- L: many machines, sensitive data, or it can change production systems.
- XL: a fleet of workers at very large scale.
Audit checklist
Every project
- Facts are verified from current official documentation
- What: Commands, libraries, APIs and platform policies in the project come from current official documents, not from memory.
- How to check: Open the dependency list and the platform configuration; for each non-trivial choice find the official page it relies on (link in a comment or a decision note).
- Evidence: Decision note or code comment with the official URL and the date it was checked.
- No secrets in code, chat, commits or logs
- What: Passwords, keys and tokens live in environment variables or a secret manager;
.envis ignored by git; the repository has only.env.example. - How to check: Check
.gitignorefor.env; run a secret scanner (for example gitleaks) over the full history; search for key-like strings. - Evidence:
.gitignoreline, scanner report with zero findings,.env.examplepath.
- What: Passwords, keys and tokens live in environment variables or a secret manager;
- Reports separate “written”, “tested” and “works end to end”
- What: Status reports say clearly whether something is written, passed its tests, or was run end to end; skipped or failed steps are stated.
- How to check: Read the last HANDOFF or release notes; look for features reported as done that have no test or run record.
- Evidence: HANDOFF lines or a test log for each feature marked done.
- Project memory files exist and are current
- What: The repository has CLAUDE.md or AGENTS.md (permanent rules) and HANDOFF.md (where we stopped), updated at the end of every work round.
- How to check: Look in the repository root for both files; compare the HANDOFF date with the latest commit date.
- Evidence: File paths and the date of the last HANDOFF update.
- The worker runs in a sandbox with least privilege
- What: The agent or worker runs as a limited user (or in a container) and can touch only the folders and resources it needs.
- How to check: Check which user runs it and what the container or OS profile allows.
- Evidence: Service definition; permission listing.
- File paths cannot escape the allowed folder
- What: Every path from outside input is resolved and checked to stay inside the allowed directory (no
../, no symlink escape). - How to check: Read the file access code; test with
../../etc/passwdstyle paths and symlinks. - Evidence: Escape test names and results.
- What: Every path from outside input is resolved and checked to stay inside the allowed directory (no
- Commands have an allow list and a time limit
- What: The worker runs only listed commands with arguments passed as an array (no shell string building), each with a timeout and output limit.
- How to check: Search for shell execution with concatenated strings; read timeout settings.
- Evidence: Allow list; timeout values.
- There is a safe stop and restart
- What: The owner can stop the worker at any time; stopping finishes or cancels the current step cleanly and a restart resumes without duplicating work.
- How to check: Stop the worker during a job and restart it.
- Evidence: Test record.
+ If it has users, personal data or API keys (M)
- One package manager, lockfile committed
- What: Exactly one package manager is used and enforced; the lockfile is committed; installs are done from the lockfile (for example
--frozen-lockfile). - How to check: Look for a lockfile in the repository and a rule that forbids other managers; check the CI and Docker install commands.
- Evidence: Lockfile path; install command lines.
- What: Exactly one package manager is used and enforced; the lockfile is committed; installs are done from the lockfile (for example
- Destructive actions need human approval
- What: Deleting, overwriting, sending or spending actions require explicit approval from the owner, with a clear description of what will happen.
- How to check: List actions that change state outside the sandbox and find the approval step.
- Evidence: Approval flow code; sample approval record.
- The local control interface is private and authenticated
- What: Any local API or socket listens only on localhost (or a Unix socket) and requires a token; browser pages cannot call it.
- How to check: Check the listening address with a socket listing tool; try a call from a web page and without the token.
- Evidence: Listening address; rejected-call tests.
- Every action is logged
- What: The worker records what it did, when and for whom, without secrets, so the owner can review it.
- How to check: Run an action and find its log entry.
- Evidence: Sample log lines.
- CPU, memory, disk and run time are limited
- What: Runaway jobs cannot fill the disk or use all memory; limits are set and tested.
- How to check: Read the service or container limits; run a heavy job.
- Evidence: Limit settings; test notes.
- External API keys stay on the server
- What: Third-party API keys (including LLM keys) are kept on the server and never shipped to the browser or app.
- How to check: Search the client bundle and app package for key-like strings; check that client calls go to your own server.
- Evidence: Search result with zero keys in the client build.
- Logs contain no personal data or secrets
- What: Logs do not record passwords, tokens, keys or personal data; if needed they are masked.
- How to check: Read the logging setup; trigger a login and a form and inspect the log lines; search for e-mail and token patterns.
- Evidence: Sample log lines after a test run showing masking.
- Personal data fields are documented
- What: For every personal data field the purpose, retention time and legal basis (KVKK, GDPR) are written down.
- How to check: List the database columns and form fields with personal data; find the matching entries in the data note.
- Evidence: Data note listing each field with purpose, period and basis.
- Critical flows have automated tests and a local check
- What: Login, saving data, payment (if any) and permission checks have automated tests; one local command runs the checks before pushing.
- How to check: List the test files; run the check command; look for a git hook that runs it.
- Evidence: Test names and a passing run log.
- Secret scanning runs before push and in CI
- What: A scanner (for example gitleaks or secretlint) runs before code is pushed and in CI.
- How to check: Find the hook or CI step that runs the scanner.
- Evidence: Hook file or CI step; latest clean run.
+ If it has an admin panel, file uploads, many users or a store app (L)
Items for class L: see Local worker / on-device agent: classes L–XL checklist.
+ If it targets millions of users (XL)
Items for class XL: see Local worker / on-device agent: classes L–XL checklist.
Common mistakes
- Running as an administrator or root because it is easier.
- Joining a user-supplied file name to a base folder without checking the result.
- Building a shell command from text that includes user input.
- No timeout, so one stuck command blocks everything.
- A local control port open to every program and web page on the machine.
- Deleting or sending data without asking the owner.
- No log of what the worker did.
- No way to stop it safely in the middle of a job.
Example projects
- Folder organizer that renames files: local worker, S.
- Backup agent on a laptop: local worker, M.
- AI agent that edits files and runs tests: local worker, M, approvals matter.
- Print-job daemon in an office: local worker, M.
- Server housekeeping agent: local worker, L.
- Report generator on a schedule: local worker, M.
- Home automation hub: local worker, M.
- Data sync agent on customer machines: local worker, L.
- Build runner for a team: local worker, L.
- Email-sorting agent with account access: local worker, L, personal data.
- Monitoring collector: local worker, M.
- Fleet of kiosks managed remotely: local worker, L.
Sources
- OS Command Injection Defense Cheat Sheet — OWASP Cheat Sheet Series
- Input Validation Cheat Sheet — OWASP Cheat Sheet Series
- Secrets Management Cheat Sheet — OWASP Cheat Sheet Series
- Logging Cheat Sheet — OWASP Cheat Sheet Series
- Docker Security Cheat Sheet — OWASP Cheat Sheet Series
- Docker Engine security — Docker Docs
- Model Context Protocol: Security Best Practices — Model Context Protocol
- OWASP Gen AI Security Project: LLM risks — OWASP Gen AI Security Project
- LLM Prompt Injection Prevention Cheat Sheet — OWASP Cheat Sheet Series
- Pro Build Guide v1.2: compiled team practices — Pro Build Guide