{"id":"XE-0059","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"80","source_url":"https://github.com/xeprotocol/xe/issues/80","reporter_id":25,"title":"docs/openapi: chat read proof described two ways; following the /chat/auth/challenge description (raw bytes, no pub_key) fails with 403/401 (Minor)","area":"sdk-docs-web","claimed_tier":"minor","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:19.914055+00:00","updated_at":"2026-11-10T11:38:22.544323+00:00","source_created_at":"2026-10-26T20:44:11+00:00","told_at":"2026-11-10T00:15:46+00:00","status_changed_at":"2026-10-29T14:04:13.333178+00:00","url":"https://bounty.xe.network/XE-0059","body":"- Suggested tier: Minor (\"documentation errors\")\n- Area: docs and openapi.json for `GET /chat/auth/challenge`, `/chat/messages`, `/chat/contacts`, `/chat/events`\n- Found: 2026-10-26, node `xe/92d83d1`, openapi.json 1.0.0\n\n## Summary\n\nThe OpenAPI document and https://test.network/docs/api give two different recipes for the chat read ownership proof:\n\n1. `getChatAuthChallenge` description: \"Sign it with your account key (**ed25519 over the raw challenge bytes**) and pass **account, challenge, and sig**\".\n2. `sig` parameter and the `ownershipProof` security scheme: \"ed25519 signature over **sha256(\"xe/chat-read-auth/v1\\0\" || challenge)**\", with `pub_key` required.\n\nThe node implements only the second (`api/chat_auth.go`, `chatSignTarget`). Following the endpoint description, the first thing a developer reads, fails twice: the raw signature is refused with 403, and leaving out `pub_key` (as both the challenge and the `listChatMessages` descriptions suggest) is refused with 401.\n\n## Evidence\n\nTested on 2026-10-26 against our own empty inbox only, on `https://ldn.core.test.network` and `https://test.network/api/v1` (same result on both):\n\n```\nA raw challenge bytes (challenge description): 403 {\"error\":\"ownership proof failed: signature verification failed\"}\nB sha256(domain||challenge) (sig parameter)  : 200 []\nC as B but no pub_key (endpoint descriptions): 401 {\"error\":\"chat read requires an ownership proof (pub_key + challenge + sig); GET /chat/auth/challenge first\"}\n```\n\nCode (`api/chat_auth.go`, master `9787859`):\n\n```go\nconst chatAuthDomain = \"xe/chat-read-auth/v1\\x00\"\n\nfunc chatSignTarget(tokenBytes []byte) []byte {\n\th := sha256.New()\n\th.Write([]byte(chatAuthDomain))\n\th.Write(tokenBytes)\n\t...\n```\n\nPlaces that say \"raw challenge bytes\" or omit `pub_key`:\n\n- openapi.json, `GET /chat/auth/challenge` description\n- openapi.json, `GET /chat/messages` description (\"pass account, challenge, and sig\")\n- https://test.network/docs/api and llms-full.txt (same text, generated from the spec)\n\nPlaces that are correct: the `sig` and `pub_key` parameter descriptions, the `ownershipProof` scheme, and the \"Authentication\" paragraph of the developer portal.\n\n## Steps to reproduce\n\nThe script below reads the test seed from a local `.env`, signs a fresh challenge three ways and reads only the signer's own inbox.\n\nRun with `python3 chat_auth_test.py https://ldn.core.test.network`.\n\n```python\n# Test the documented chat read proofs against our own (empty) inbox only.\n# The seed is read from .env and never printed.\nimport hashlib, json, sys, urllib.request, urllib.error, urllib.parse\nfrom pathlib import Path\nfrom nacl.signing import SigningKey\n\nENV = Path(\".env\")  # file with XE_TEST_SEED_HEX=<64 hex>\nseed = bytes.fromhex([l.split(\"=\", 1)[1] for l in ENV.read_text().splitlines() if l.startswith(\"XE_TEST_SEED_HEX=\")][0])\nsk = SigningKey(seed)\npub = bytes(sk.verify_key).hex()\nacct = hashlib.sha256(b\"xe/account/v1\" + bytes(sk.verify_key)).hexdigest()\nBASE = sys.argv[1]\n\ndef get(path):\n    try:\n        with urllib.request.urlopen(BASE + path, timeout=30) as r: return r.status, r.read().decode()\n    except urllib.error.HTTPError as e: return e.code, e.read().decode()\n\ndef challenge():\n    return json.loads(get(\"/chat/auth/challenge\")[1])[\"challenge\"]\n\ndef read(sig_target_fn, include_pub=True):\n    ch = challenge()\n    sig = sk.sign(sig_target_fn(bytes.fromhex(ch))).signature.hex()\n    q = {\"account\": acct, \"challenge\": ch, \"sig\": sig}\n    if include_pub: q[\"pub_key\"] = pub\n    s, b = get(\"/chat/messages?\" + urllib.parse.urlencode(q)); return s, b[:160]\n\nraw = lambda b: b\nhashed = lambda b: hashlib.sha256(b\"xe/chat-read-auth/v1\\x00\" + b).digest()\nprint(\"A raw challenge bytes (challenge description):\", *read(raw))\nprint(\"B sha256(domain||challenge) (sig parameter)  :\", *read(hashed))\nprint(\"C as B but no pub_key (endpoint descriptions):\", *read(hashed, include_pub=False))\n```\n\n## Impact\n\nIntegrators following the endpoint description cannot read chat. Documentation only; replay protection was checked and works (a second use of a challenge returns `challenge already used`, and a challenge from one node is refused by another with `challenge not issued by this node`).\n\n## Suggested fix\n\nChange the challenge and `listChatMessages` descriptions to: \"Sign sha256(\"xe/chat-read-auth/v1\\0\" || challenge bytes) with your account key and pass account, pub_key, challenge and sig.\"\n\n## Payout\n\nXE address: `6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc` (same as #75).\n","patch_refs":[],"thread":[{"id":1574,"source":"github","source_ref":"6755093783","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0059.","created_at":"2026-11-10T00:15:46+00:00"}]}