All insights

The log file was the way in

A log file is a write primitive. If the unprivileged side can replace it, it can write wherever the privileged side can.

I gave the assistant that runs my daily jobs its own account on the machine, with no administrator rights, and a shared folder where it drops work for me to pick up. That is the textbook shape. Two days later I went looking for what the shape actually permits and found that the assistant could have run commands under my account, not through anything clever, but through a log file. A scheduled job of mine wrote its output to a fixed path inside that shared folder. Whoever can replace that file decides where the output goes.

Two accounts and a shared drawer

The setup is ordinary. One account belongs to me and owns everything. A second account runs the automated assistant, has no administrator rights, and cannot read my home directory. Between the two sits a shared folder with a handful of working directories: one for state, one for finished output, one for material I hand over. Both accounts write there. That is the whole point of it.

The permissions on those directories were group-writable with the group-inherit bit set, which is what makes shared work possible at all. What they did not have was the sticky bit. Without it, write permission on a directory means permission to delete or replace any file in it, including files owned by someone else. Both accounts could therefore remove each other's files. I had read that line many times before I understood what it buys an attacker.

A log is somewhere to write

My scheduled job ran as me. It wrote a log file and a lock file to fixed names inside those shared directories. The assistant's account could delete both and put a symbolic link in their place, pointing anywhere I could write.

The scheduler follows that link. I did not want to take this on trust, so I built a throwaway scheduled job, pointed its output at a symlink, and watched: it opened the link's target and appended to it, as me. The in-process writer behaved the same way. The lock file was worse in a quieter direction, because opening a file for writing truncates it, and truncating a symlink truncates its target.

That turns a log into a writing tool. The content of each log line included a filename, and the filenames came from the assistant's own output directory, so the assistant chose part of what got written. Point the link at my shell startup file, drop a file whose name is a command, and the next time I open a terminal the command runs as me. A file rename across a linked directory had a similar shape, though it could only plant files with one extension.

An account boundary holds only where the privileged side never writes to a path the unprivileged side controls.

What the fix actually was

Three things, in order of how much they matter.

  • The logs and locks of every job that runs as me moved out of the shared tree entirely, into a directory under my own library folder that the other account cannot traverse. This covers both the scheduler's own output redirection and any writing the process does itself. One constraint from an earlier incident applied here: that directory cannot live under the synced documents folder, where the scheduler refuses to start at all.
  • The sticky bit went on every shared writable directory. Each account can still create files and still delete its own. Neither can delete the other's any more.
  • For the writers that genuinely have to stay in the shared tree, the file is opened with the flags that refuse to follow a link and refuse to open an existing file, the final move is an atomic replace, and the target directory is checked with a call that does not follow links before anything is written.

None of this is sophisticated. It is three lines of permission change and one file-open pattern. What took the time was seeing that a log file counted as an attack surface at all.

The guardrail that blocked its own repair

One detail is worth keeping because it will recur. The assistant that found this could edit the code but could not apply it. The permission changes and the scheduler reload are exactly the class of live system mutation its own guardrails refuse, so the edits sat ready and I ran the two commands by hand in a terminal.

That is the correct outcome, and it is also a reminder about how these boundaries are actually maintained. The part a machine can do is the analysis and the patch. The part that changes the running system stays with a person, which means the fix is only live when that person sits down. Between finding and fixing, the hole is still open, and the honest way to treat that window is to count it, not to describe the problem as solved on the day it was understood.

Key

When you give an agent its own account, list every fixed path your privileged jobs write into shared space. Each one is a place the agent can point somewhere else.

Hung Mai

Hung Mai is an independent consultant in Weilmünster, Germany, mostly working remotely. He plans, builds and monitors AI automation for marketing and sales for companies without a digital team. About Hung Mai

Let's build something real.

Let's talkResponse within 24h.