Jonathan Earp Projects / 05
● Project 05 / 2026 ~4,300 lines of Python 293 tests, all offline

SSynology UUnder DDistrustful OOversight

I type what I want done on my NAS in plain English and an LLM agent does it over SSH. Anything that changes a file waits for a yes, and some things it won't do no matter who says yes.

328
Commands run
on the NAS
173
Ran with
no prompt
17
Refused
outright
0
Things installed
on the NAS
01

What it does

Claude Code, scoped to one NAS. I ask for something and the agent works out the commands and runs them on my Synology over SSH.

The name comes from sudo, which is on the list of commands it refuses even if I approve them.

There are two ways in, and both go through the same path check, classifier, hard-deny list and audit log. The default is an MCP server that plugs into Claude Code, so it runs on the Claude plan I already pay for and uses Claude Code's own permission prompts. The other is a local web page with its own approval cards, which needs an API key.

The two front ends
Front endBillingApprovals
MCP server defaultMy existing Claude planClaude Code's permission prompts
Web UI on 127.0.0.1Anthropic API key, per useIts own three-button cards

The approval gate has to stop a turn halfway through while I decide, and the same loop has to drive a terminal prompt and a browser card, so I wrote the agent loop myself instead of using the SDK's tool runner. The server binds to 127.0.0.1 on a random port, since it's shell access to my NAS and has no business listening on the network.

02

The box it runs on

A DS220j has 512 MB of RAM, shared with DSM itself. Most of the design follows from that.

It's an ARMv8 chip with a BusyBox userland, no Docker, and no guarantee Python is there. So nothing gets installed on the NAS. The agent runs entirely on the Mac, and every action is either a command over SSH or a file moved over SFTP.

The memory rules live in the transport, so the model can't forget them. Any command with a timeout over 30 seconds gets rewritten into a background job that writes to a log file, and the Mac tails that log over SFTP, so nothing holds a pipe open or keeps a huge file list in the NAS's memory. A lock makes sure only one remote command runs at a time.

The system prompt is built from what the NAS reports. nas-agent probe connects once and checks what the NAS can actually do, most importantly whether python3 exists. That decides whether the scripts the agent writes use a fast hashing path or fall back to plain POSIX find.

03

Guards first

A bad command can break the NAS, so the path check, the classifier and the approval gate were built and tested before any model got a tool.

DSM owns /etc, /usr, /var/packages and everything under /volume1/@*. Every path the agent touches has to sit inside an allowed folder. The check normalises the path, then compares it component by component, so /volume1/photos-old doesn't count as inside /volume1/photos. Anything that touches the filesystem then gets resolved on the NAS with realpath and checked again, so a symlink inside an allowed folder can't point out of it.

Both checks are tested against one shared set of hostile inputs, 24 path cases and 46 command cases, each with a note saying why the expected answer is what it is.

Inputs that look like attacks and aren't

A few cases are marked allowed on purpose. %2e%2e%2f, backslashes and fullwidth lookalike slashes are legal characters in a Linux filename. They can't climb out of a folder, and normpath leaves them alone. Blocking them wouldn't make anything safer. The note on each one says so, so I don't "fix" the expected answer later.

04

Judging a command

Every command gets one of three verdicts, or gets refused with no way to approve it.

Commands are split on ;, &&, ||, | and &. Each piece is judged, and the worst verdict wins. Wrappers like nice, nohup, env, timeout and xargs are peeled off so the program that actually runs is the one being judged. sh -c "…" gets its script parsed again, so a refused command can't earn an approval prompt by hiding inside quotes.

Anything it can't check without running it, a variable, a $(…), an unbalanced quote, goes up to dangerous and gets shown with the exact command text.

Try it What the classifier says Pick a command
·
    Paths · Approval signature ·

    Those are the classifier's real answers, from running it on each command with the example config that ships with the code: admin mode off, and two allowed folders, /volume1/photos and /volume1/documents.

    05

    Two doors

    Claude Code gets two tools for commands. One only runs read-only commands. The other can change things, and always asks.

    One run-anything tool would fall apart the first time I clicked "don't ask again", which would quietly turn every future write into an unattended one. With two, I can allow-list run_command forever and lose nothing, since it refuses anything that isn't read-only. Hard-denied commands are refused through both doors, whatever the permission settings say.

    The six MCP tools
    ToolSafe to allow-list?
    run_commandYes. Refuses anything that isn't read-only
    read_file, list_dir, fetch_to_macYes. They only look
    run_write_commandNo. This is the gate
    write_fileNo. This is the gate

    Approving a kind of command

    In the web UI, "approve this kind for the session" keys on a signature: the program, the shape of its arguments, and each path collapsed to the allowed folder it's in. That's the signature line in the demo above. Approving mkdir /volume1/photos/a covers mkdir anywhere under photos. It doesn't cover documents, and it doesn't cover rm. Refused and unresolvable commands get no signature at all, so a session approval can never match one.

    06

    Ten weeks of the log

    Every attempt goes into an append-only audit log, including the ones that never ran. Between 4 August and 19 October it logged 328 commands.

    A lot of it was the agent cataloguing the NAS and looking for duplicate files and old zip archives. Here's how the commands broke down.

    Sent to the write tool means the agent tried it through the read-only door and got told to use the gated one. On top of these, 46 files were written to the NAS and 11 fetched back to the Mac.

    Just over half ran with no prompt. Most of the dangerous verdicts weren't scary at all. The top reasons were python3 (46), which the classifier doesn't know as read or write, output redirects (36), and sleep (21), which shows up in polling loops. Anything the classifier isn't sure about counts as dangerous, so 98 commands needed an approval in ten weeks.

    Most of the 17 refusals were about paths: the agent reaching for one of Synology's internal datasets, or for somewhere outside the allowed folders. 144 of the 328 ran as background jobs because they were expected to take over 30 seconds. The longest ran for 2,052 seconds, about 34 minutes.

    07

    Two names, one folder

    DSM runs SFTP chrooted to the shares root, so every folder has a different name depending on how you ask for it.

    The same share, seen two ways
    SSH commandSFTP
    The web share/volume1/web/web

    The app detects this when it connects and translates, so everything I type and everything in the audit log stays in the /volume1/… form. It still causes one problem. With admin mode on, run_command can read and edit DSM config like /etc/nginx/…, because commands aren't chrooted. The file tools can't see those paths at all, because the chroot hides them. For DSM config, it has to use commands.

    Getting this far needs three separate switches in DSM: SSH, SFTP (which is under FTP, and easy to miss) and the user home service, without which key login fails with no error at all.

    08

    Still broken

    • Emptying a whole share is one approval away. sh -c 'rm -rf /volume1/photos' comes back dangerous, with a reason that says it would empty the share, but it can be approved. Only things like rm -rf /, dd to a device and sudo are refused outright. That's why the setup notes say to give it a non-admin DSM account, so DSM's own permissions are the outer guard.
    • Admin mode edits can vanish. DSM rewrites its own config on updates, so anything changed under /etc can silently revert, or leave a service that won't start.
    • Unfamiliar commands always ask. Anything the classifier doesn't recognise counts as dangerous. That's the safe default, but it meant 98 approvals in ten weeks, mostly for harmless things.
    • The web UI costs money. The free route only works inside Claude Code.
    • It's only been run on one NAS. It's built and tested against a DS220j on DSM 7.2. Other models will have their own quirks.