Boundaries that were supposed to hold
The security pass. Six findings, none reachable by visiting the site and every one a boundary this codebase says it keeps. A subagent is pinned to a list of read-only commands, in every mode, unattended, with no card anybody could approve -- and `find *` was on it. find writes files with -fprintf, runs programs with -exec and removes them with -delete, and none of that needs a character the metacharacter guard refuses. A page the model had just read could ask for a helper and get a key into authorized_keys, from Plan mode, which promises to change nothing. Refused in `subject()` rather than trimmed from the list: a pattern cannot say "and no dangerous flags", and "this one looks read-only" is exactly what put find there. The loopback guard missed `0.0.0.0`, which is not is_loopback but does connect to localhost -- so it answered a *decided* False and skipped the DNS half too. The one spelling of "this machine" that walked past a guard whose whole job is that sentence. Twice in the update helper, which is the one place this deliberately crosses a privilege boundary: root ran a script the service account owns, and root sourced a file that account can replace. Either turns a compromise of the web application into root. The first needed no compromise at all -- a pull happens as the service user and root runs whatever it fetched, so control of the branch was control of root. The old test asserted that exact ExecStart line and had pinned it in place. Push endpoints skipped check_url, the only outbound request that did. And a chat could be filed in another account's folder, which hands over its system prompt -- `_new_chat` resolved the folder, discarded it when it was not the caller's, and stored the raw id anyway. An existing helper install keeps the old wiring until install.sh is re-run; update.sh now says so when it finds itself inside the checkout. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -436,3 +436,41 @@ def test_moving_respects_the_depth_cap(client: TestClient, db, registered):
|
||||
refused = client.patch(f"/api/folders/{loose}", data={"parent_id": chain[-1]})
|
||||
assert refused.status_code == 400
|
||||
assert db.get(Folder, loose).parent_id is None
|
||||
|
||||
|
||||
def test_a_chat_cannot_be_put_in_somebody_elses_folder(client: TestClient, db, registered):
|
||||
"""A folder is not just a label. `effective_system_prompt` walks up from the
|
||||
chat through its folder and that folder's parents, so a chat attached to
|
||||
another account's folder would take their system prompt -- a setting read
|
||||
across an ownership boundary through a field that looks like a tag.
|
||||
|
||||
Both paths had it. `_new_chat` resolved the folder, discarded it when it was
|
||||
not the caller's, and then stored the **raw id** anyway -- so the check
|
||||
governed which seeds were applied and not where the chat went.
|
||||
"""
|
||||
from lembas.security.passwords import hash_password
|
||||
|
||||
stranger = User(name="Sam", email="sam@shire.test", password_hash=hash_password("x"))
|
||||
db.add(stranger)
|
||||
db.commit()
|
||||
theirs = Folder(user_id=stranger.id, name="Private", system_prompt="Speak as Sam.")
|
||||
db.add(theirs)
|
||||
db.commit()
|
||||
|
||||
mine = db.scalar(select(User).where(User.email != "sam@shire.test"))
|
||||
chat = Chat(user_id=mine.id, model_id="m")
|
||||
db.add(chat)
|
||||
db.commit()
|
||||
|
||||
client.patch(f"/api/chats/{chat.id}", data={"folder_id": theirs.id})
|
||||
db.refresh(chat)
|
||||
assert chat.folder_id is None
|
||||
|
||||
started = client.post(
|
||||
"/api/chats/start",
|
||||
data={"content": "hello", "folder_id": theirs.id},
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert started.status_code in (200, 204, 303)
|
||||
made = db.scalars(select(Chat).where(Chat.id != chat.id)).all()
|
||||
assert all(c.folder_id != theirs.id for c in made)
|
||||
|
||||
Reference in New Issue
Block a user