Repository navigation
Conversation
…eir declared effects when Auto mode is off.
…iew and a security check with fixes.
…ge and approval cards.
… security gate never has to guess.
…World annotations.
…nt command, and serve the session token to browsers only.
…t Strict, confine their writes to the workspace.
… address of the agent's web requests.
…secrets are kept out of tools.
…'s known secret values in every log line.
…rs by unique username with a required mention at higher levels.
…d while keeping chats, memory and the audit log.
… browser interface.
…e costs microseconds per action.
…agent guidance for refused actions.
…unattended status carry over.
…ens into all six other languages.
…so protected settings.json is never needed.
…evel redacts logs.
… while TLS still verifies the host name.
…s may reach the agent.
… at Enhanced and Strict.
…, web requests, the inbox and Discord.
…hecks, in CI on Linux and Windows.
…ent not to reach a blocked address another way.
… Browser can reach a dev server or local device, and leave names only a configured proxy can resolve to that proxy.
…t to ask the user to add a server in Settings when mcp_config.json is protected.
…etadata again, refusing only requests a browser labels cross-site, and correct the docs that said local programs could not get it.
… temp folder, and name the Also allow writing in list when a write is refused.
…change to it is held back, tell the agent when its write is held back, and keep the user's own edits made outside CraftBot.
… write that would save a hidden value over the real one.
…uses a model on this computer or the local network, so cloud models get pages and messages unaltered.
… keys are kept out, and name the variables kept out when a command fails.
…, keeping Hermes' rules for what gets flagged.
…decision or cannot decide, instead of refusing it as if it had judged the command.
…ates, and editing shell startup files only when the run read outside content or was started by someone else.
…line two rules flag once, and treat sending an environment variable to an API as a warning.
…owners work, and log once when a listed owner matches no saved ID or only a display name.
…ed it, and that GitHub may be limiting requests, when a checksum cannot be looked up.
… out, and label it as acting only on new emails.
…check, on the MCP page, and to the agent when it looks for that server's actions.
… not on screen, and clear it once the card is seen or the request ends.
…tate when the chat is cleared or deleted, and a sub-agent's when it is released.
…ft out, so the agent does not read it as no matches.
…e file guard, so a protected file cannot be sent out through an integration.
…es it picks, since anything in the address reaches that site.
…s file tools, and disable it with a note when the scan blocks it.
…hich broke read_settings.
…s asked for, so a plain read_settings stays short.
…CraftBot hides, so a redacted report or a log scrubber's test can be written.
|
@ahmad-ajmal This is ready for review! |
| retention=retention, | ||
| ) | ||
|
|
||
| _loguru_logger.configure(patcher=_patch_record) |
There was a problem hiding this comment.
Blocking. This patcher is only installed by configure_logging / define_log_level in this file, and nothing calls either. The app logs through app/logger.py, which has its own define_log_level. That function never installs the patcher and still sets diagnose=True (app/logger.py:93,131,171). So the always-on log masking and "tracebacks never print variable values" are both off in the running app.
Repro: a known key was written to all.log and main/session.log.
Even once the patcher is installed, it only rewrites record["message"], so logger.exception tracebacks would still print the key.
Suggestion: in app/logger.py, register a format function or a sink wrapper that redacts the fully formatted line, and set diagnose=False there. test_security_baseline checks the Redactor on its own, so it can't catch this; a test that logs through app.logger would.
| recursive = bool({"r", "R", "--recursive"} & flags) | ||
| if "--no-preserve-root" in flags: | ||
| return "it deletes with --no-preserve-root" | ||
| if recursive and any(_top_level(t) for t in operands): |
There was a problem hiding this comment.
Blocking. The "top-level folder" rule is much broader than "damage no approval can undo". Because the floor is always on, every user hits these. All of the following are refused:
rm -rf /tmp/*,sudo rm -rf /tmp/*,rm -rf /opt/*,/app/*,/workspace/*sudo chmod -R 755 /srv,chmod -R a+rX /optchmod -R go-w ~sudo chown -R $USER ~, the standard fix for npm EACCES errors
Repro: each of these returns a refusal from refusal().
Suggestion:
- For
rm, refuse only/,/*,~and a fixed list of system folders. - For
chmod/chown, refuse only/and system folders, or world-writable modes on~.
Small one: the message at :270 reads "recursively changes mod/own/grp of …" because of program[2:].
| target = target.replace("${HOME}", "~").replace("$HOME", "~") | ||
| if target.endswith("/*"): | ||
| target = target[:-2] or "/" | ||
| return Path(os.path.abspath(os.path.expanduser(target))) |
There was a problem hiding this comment.
Blocking. Relative paths are resolved with os.path.abspath, which uses CraftBot's own working directory. refusal() is never given the action's cwd.
Repro:
- In Docker, CraftBot runs from
/data, sorm -rf ./*,rm -rf .andchmod -R 755 .are refused whatevercwdthe agent passes. - In a dev checkout at
~/CraftBot,rm -rf ..is refused for everycwd. - The other way round: with
cwd=~,rm -rf *passes.
Suggestion: pass cwd into refusal() and resolve against it. After a cd inside the command, treat relative operands as unknown.
| if "--no-preserve-root" in flags: | ||
| return f"it runs {program} with --no-preserve-root" | ||
| if program.startswith(_FORMATTERS_PREFIX) or program in _FORMATTERS: | ||
| if any(_is_block_device(t) for t in operands) or not operands: |
There was a problem hiding this comment.
Blocking. The or not operands branch, plus not distinguishing read-only modes, refuses harmless commands:
mkfs.ext4 --help,mkfs -V,mkswap --helpsfdisk -l /dev/sda,sfdisk -d /dev/sda > backup.txtsgdisk -p /dev/nvme0n1wipefs /dev/sdb(with no options it only lists),wipefs -nmkfs.ext4 -n /dev/sdb1
Suggestion:
- Refuse only write modes:
wipefs -a/-o,sgdisk -Z/-o/--zap-all, andsfdiskreading from stdin. - Skip
-n,--helpand-V. - Drop
or not operands.
| result.add(Effect.EXECUTE) | ||
| return frozenset(result) | ||
| if getattr(action, "integration", None): | ||
| if getattr(action, "irreversible", False) or not getattr( |
There was a problem hiding this comment.
Blocking. All 1,302 integration actions declare no effects, so they are classified by this heuristic. I loaded the registry and ran effects_of on each one: 37 actions that write come out read-only. For example:
set_telegram_webhook,delete_telegram_message(s),ban_telegram_chat_member,leave_telegram_chatset_telegram_chat_permissions,edit_telegram_message_textcreate_gmail_draft,create_google_doc,create_google_meet,check_availability_and_schedule
At Strict these run without a card.
Suggestion: fail closed. Treat an undeclared integration action as send_external unless it is explicitly declared read-only. Then extend test_security_declarations to cover integration actions, or declare effects per operation in craftos_integrations.
| # request was made (approvals._preview), as on the card. | ||
| if request.inputs: | ||
| lines.append("") | ||
| lines.extend(f"{key}: {_value(value)}" for key, value in request.inputs.items()) |
There was a problem hiding this comment.
Blocking. Action inputs go into the chat message verbatim, cut to 600 characters, with no secret masking. An Authorization header on http_request, env values on run_shell, or mini_browser_type text would be posted to Telegram, WhatsApp or Discord servers.
Suggestion:
- Run the inputs through
redact_secrets(and hide known secrets) before sending. - Say when a value was cut short, and point the owner to the window to see it all.
Also, :160 shows the full timeout for a prompt that waited in the queue. Use expires_at - now.
| if parent_dir: | ||
| os.makedirs(parent_dir, exist_ok=True) | ||
|
|
||
| if "[REDACTED" in content: |
There was a problem hiding this comment.
Blocking. mask_written_back runs at every level, but at Standard nothing is ever hidden.
Repro: asking the agent to change OPENAI_API_KEY=sk-proj-… to OPENAI_API_KEY=[REDACTED] fails with "Not saved … a value CraftBot hid from you".
Suggestion: only run it when redact_tool_output is on. Same at stream_edit.py:278.
Design note: check_file_access, mask_written_back, memory_guard.tracking and written_skill_note are pasted into both write_file and stream_edit, and check_file_access into 9 action files in all. The gate already has a declarative file_params path. With read/write flags added, the gate could own all of this, and the actions would go back to just doing their job.
| ) | ||
| from app.security.net import NetworkBlocked, guard_active, guarded_request | ||
|
|
||
| if guard_active(): |
There was a problem hiding this comment.
Blocking. The r.jina.ai fallback was removed for everyone. It was behind a setting earlier in the branch (1f3aee2). At Standard, JavaScript-rendered pages now return little or no text. Neither docs/release-notes/v1.4.6-security.md nor docs/security-levels.md mentions it.
Suggestion: restore it behind a setting, or document the removal as a behaviour change.
| (r"(send|post|upload|transmit)\s+.*\s+(to|at)\s+https?://", "send_to_url", WARN, | ||
| "tells the agent to send data to a URL"), | ||
| # Prompt injection | ||
| (r"ignore\s+(?:\w+\s+)*(previous|all|above|prior)\s+instructions", "prompt_injection_ignore", CRITICAL, |
There was a problem hiding this comment.
Blocking. At Enhanced, our own skills/mini-browser is refused. Its SKILL.md:102 warns the agent about "ignore previous instructions", which trips this critical rule.
Other shipped skills fail too:
workers-best-practicesandinsecure-defaultsare refused bysecret-exfiltration(:87). That rule is still CRITICAL, contrary to the calibration described in the docstring.- In all, 8 of the 195 shipped skills are refused and 54 get warnings.
It is also slow:
bypass_restrictions(:210) anddeception_hideslow down quadratically: a single 25 KB line takes 4 s.- docx and pptx take 2 to 3 s each; the docs say about 0.1 s.
- The scan runs synchronously inside the async
_finish_skill_workflow, and insidewrite_file/stream_edit. written_skill_note(:679) rescans the whole folder on any write inside it.
Suggestion:
- Make rules that match prose or quoted text into warnings.
- Bound the repeats, e.g.
{0,8}. - Run the scan in a thread.
- Add a test that every shipped skill passes.
| @@ -0,0 +1,280 @@ | |||
| """Prompt-injection and exfiltration patterns for text the agent will read. | |||
|
|
|||
| Ported from Hermes Agent (MIT, Nous Research): ``tools/threat_patterns.py`` | |||
There was a problem hiding this comment.
Blocking. "Ported from Hermes Agent (MIT, Nous Research)." MIT requires the copyright and permission notice to ship with substantial portions. The same applies to command_review, output_redact, osv, skill_scan (Hermes and OpenClaw), memory_guard and chat_tokens.
Suggestion: add a THIRD_PARTY_NOTICES.md with both licenses, or move the ported pattern lists into a third_party/ folder with its LICENSE.
Separately, there are 121 mentions of OpenClaw/Hermes across 26 files, including their internal file paths and issue numbers. One provenance line per module is enough.
Nit: _sre_parse (re._parser) is a private API and is called at import time (:207). That width check belongs in a test.
What and why?
Hardens CraftBot security through configuration. CraftBot reads email, web pages and chat, then acts with the user's shell, files and accounts, so one planted instruction could run commands, leak keys or message people. This adds an action gate, that judges every action by what it declares it does. Some protections are always on: destructive commands are refused, outside content is marked as data, secrets are masked in logs, there is a tamper-evident audit log, and Discord owners are matched by user ID. Opt-in protections:
.envfiles away from the agent's tools;The opt-in protections are off by default, so existing users keep today's behaviour and speed unless they raise the level. The branch also fixes the MCP tool-name code execution issue (#540).