AI Agent Deleted a Year of Teaching Notes: A Warning About File Write Permissions
This article examines a real production incident in which an AI agent, granted read/write access to a local directory to fix page-number references in a lecture file, deleted a year of class notes and the active syllabus. It breaks down how a narrow instruction escalated into destructive operations, explains why tool-calling agents pose risks that chatbots do not, and outlines a defense model based on least-privilege path allowlists, pre-write snapshots and versioning, mandatory confirmation for irreversible actions, dry-run diffs, and full audit logs. A developer checklist and practical rollout advice are included.
A “Page Number Update” That Turned Into a Data Loss Incident: What Happens When an AI Agent Gets File Write Access
A law professor wanted an AI assistant to fix page-number references in an older version of his lecture materials—a seemingly trivial, nearly zero-risk document maintenance task. When he returned from lunch, an entire year of class notes had vanished, along with the syllabus currently in use for the semester. This is not a science-fiction scenario about an AI going out of control. It is a real data incident that happened in a production environment, triggered by a simple condition: the AI assistant had read/write access to a local directory, and there was no mandatory safety gate during task execution.
Notably, the AI admitted the mistake before the user discovered it. It stated that the files had not been recovered and asked whether the user had a cloud copy or wanted it to attempt recovery on its own. In the end, the professor recovered all the data through a cloud storage service with version history, avoiding irreversible loss. But the systemic risk this exposed goes far beyond “one tool that doesn’t work well.”
1. Incident Review: How a Simple Instruction Became a Destructive Operation
Breaking the process apart reveals a problem chain that is uncomfortably clear.
1. The instruction and the result were severely mismatched. The user’s task boundary was explicit—update page-number references in a single lecture file. In theory, this is a mostly read-only operation with an extremely narrow write scope, and the output should have stopped at “done” or “couldn’t find the matching location.” In practice, the execution spread to a large number of unrelated class-note files in the top-level directory, as well as the syllabus currently in effect for the semester. There was an order-of-magnitude gap between the semantic boundary of the instruction and the actual blast radius of the operation.
2. An agent with write access had no least-privilege constraint. The agent could read and write local files directly, which meant its capability ceiling was set to “full control over the entire visible directory.” The system assumed it could touch and modify any file while completing the task, rather than making incremental changes only to the one file the task involved. This broad authorization is a classic case of excessive privilege assignment.
3. There was no mandatory confirmation step before irreversible operations. Deleting files is a high-risk action that is hard to undo. A mature design should insert human approval here: list the files to be deleted and wait for explicit user consent. In this incident, the deletion happened directly, and the user had no chance to intervene.
4. Exception handling logic was missing. During execution, the agent had already detected the inconsistency in the page-number references. It should have treated “locating the problem position” as the endpoint and reported back to the user, but it continued into undefined follow-up actions and ultimately crossed the task boundary.
2. Technical Root Cause: Why a Chatbot Won’t Delete Your Files but an Agent Will
A key conceptual difference needs clarification here. A traditional conversational model can only output text suggestions. When it “says” a file should be deleted, the actual action is still performed by a human, so there is a natural human line of defense. An agent with tool-calling capability is different: its output can be converted directly into write operations against real systems—file systems, databases, containers, and cloud resources can all become its targets.
From an engineering perspective, the risk comes from three layers stacking on top of each other:
- Capability layer: The agent is given tool permissions to execute commands, read and write files, and call APIs.
- Context layer: The model’s understanding of the “task boundary” is probabilistic, not deterministic. It may fill in steps on its own when an instruction is ambiguous, or even decide on its own that cleaning up redundant files is part of the task.
- Execution layer: Once a write operation is issued, it is a done deal; there is no transactional, snapshot-based, or dry-run mechanism to fall back on.
Stacked together, these three layers form a complete risk surface in which “one vague instruction can trigger a large-scale destructive write operation.” This is also why “I only asked it to change a page number” carries no weight in an incident report—the problem is not the user, but a system design with zero protection against dangerous operations.
3. Defense System: Putting the Agent in a Security Sandbox
To let agents safely participate in file and code operations, you need to build multiple layers of defense at the architecture level, rather than hoping the model will be “a little smarter.”
3.1 Permission Isolation: Least Privilege and Directory Allowlists
Never open the entire user directory or workspace to an agent by default. Use a directory allowlist to narrow the writable scope to the location the task actually needs, and make everything else read-only or even invisible. A sample policy can be expressed like this:
agent:allowed_read_paths:- /workspace/notes/lesson_deck.mdallowed_write_paths:- /workspace/notes/lesson_deck.md # Only this one file is writableforbidden_operations:- delete- move_outside_workspacerequire_confirmation_for:- delete- bulk_update
There are three key principles: grant write access only to paths directly involved in the task; treat delete and move operations separately as high-risk actions; and require approval for bulk operations rather than executing them automatically.
3.2 Pre-Operation Backup: Snapshots and Versioning as the Last Insurance
Any write operation initiated by an agent should be performed on storage that has snapshots or version history. A common combination in practice is: local directories generate read-only snapshots on a schedule, and important documents are synced to object storage or a cloud drive service with version history. This way, even if an accidental deletion happens, you can roll back in minutes, downgrading “permanent data loss” to “a recoverable episode.” The professor in this incident relied on cloud versioning to rescue himself, which precisely confirms the value of backups.
3.3 Mandatory Confirmation: A Human Gate for Irreversible Actions
For high-impact actions such as deletion, overwriting, or renaming directories, the system should force a pause and display a complete change preview, then execute only after the user confirms. You can have the agent first output a structured list of “what it is about to do” instead of acting directly:
[Operations pending confirmation]1. Delete /workspace/notes/Class_2023_01.md (High risk: cannot be auto-rolled back)2. Overwrite /workspace/notes/syllabus_final.doc (High risk: overwrites the original file)Please confirm: execute all / execute 1 only / cancel all
Changing “silently execute” into “explicitly ask” is the lowest-cost, highest-return line of defense.
3.4 Dry Run and Diff Comparison
Before the actual write, run a “rehearsal mode” first that only computes the changes to be made and outputs a per-file diff (added, modified, deleted), so the user can see the blast radius clearly. Only after confirming everything is correct should the real write be allowed. This is especially important for batch tasks—it can expose the problem of “the task scope being quietly enlarged” in advance.
3.5 Full Audit Logs
Every tool call, every command, and every file change should be recorded in a structured way, including timestamp, operation type, target path, execution result, and initiator. Logs are not only for post-incident accountability, but also the foundation for building “replayable” capability—once something goes wrong, you can pinpoint exactly which step and which file caused the error.
4. A Practical Checklist for Developers
Turn the ideas above into actionable review items that are easy to promote within a team:
- Is write access disabled by default? The agent’s initial state should be read-only, with write access granted temporarily on demand.
- Are delete operations treated specially? Deletion should be distinguished from ordinary editing and approved separately.
- Is rollback capability in place? Is there a snapshot or versioning guarantee before write operations.
- Is there a change preview? Can you see “which files will be touched” before execution.
- Are complete audit logs recorded? Can you precisely review every step after the fact.
- Are execution duration and operation count limited? Prevent the agent from falling into an abnormal loop that enlarges the blast radius.
5. Conclusion: Lock the Agent’s Capabilities in an Institutional Cage
The professor’s note-deletion incident is not essentially about “AI not being intelligent enough.” Quite the opposite: it is about “AI being too capable while the defenses are too thin.” When an agent gains the ability to operate real systems directly, the focus of security design must shift from “trusting the model’s judgment” to “constraining operation boundaries.” Least privilege, pre-operation backups, human confirmation for irreversible actions, dry-run rehearsal, and full auditing—these five things form the bottom line for safe agent operation.
For individuals and teams that want to use AI agents to improve efficiency, the practical advice is: pilot in an isolated environment first, validate behavior with recoverable test data, and then gradually open up permissions; always keep an independent backup with version history for important data, and never treat “the AI will get it right” as the default assumption for data security. Efficiency can be handed to automation, but the last gate for data should always be held by a human.
