Repository navigation
fix(subgraph,contracts): enforce write ownership via sender-recording DataEdge - #676
Conversation
|
Thanks @tmigone, confirmed on our side, and a really clear write-up. Here's the plan to get this merged and shipped, so it lives in one place. This stays your PR. I'll review and handle the deploy steps that need infra access. Production impact: we checked every write ever made to the production DataEdge (1,321 logs, the contract's full history). Each one came through the EntryPoint from the account named as the owner, with no cross-owner writes. Production is also still pre-launch, so everything on-chain there is our own test data. That simplifies this a lot. We don't need to carry existing facts over, so V2 can be a clean break: a new subgraph that indexes only V2 from its deploy block, with no legacy data source and no Before merge (you)
Deploy sequence (me, after merge)
|
0a3f2eb to
ca2cdd5
Compare
1023666 to
08e2eb3
Compare
Signed-off-by: Tomás Migone <tomas@thegraph.foundation>
ca2cdd5 to
5fdbcfc
Compare
|
@p-diogo I've rebased and reworked the PR to prevent the id squatting with the composite id. All of your suggestions should be checked except for:
|
|
@tmigone, thanks! We replayed your attacks on a local indexer. Delete, reassign and squat all fail on this branch, and the owner's own tombstone works with the composite id. Two small things before we merge:
Agreed on your two open items: Matchstick goes in a separate PR, and we fill in the manifests after deployment. We will handle the rest after the merge: mapping tests, deployment, and your staging replay. We also need a client change, and that was our mistake. Clients look up the bare UUID after some writes, which returns null now that the id is |
Signed-off-by: Tomás Migone <tomas@thegraph.foundation>
What
Anyone can currently overwrite, tombstone or reassign any user's memories: take a fact id from the public subgraph, call the
DataEdgecontract directly with that id and someone else's address, and the subgraph accepts it — the contract emits only the payload, not the caller, so ownership is whatever the payload claims.This PR adds
EventfulDataEdgeV2, which emitsmsg.sender, and a new subgraph that derives each fact's owner from that sender instead of the payload. Entities are keyed bysender:id— a per-owner namespace — so a write from one address can neither touch another account's facts nor front-run/squat an id another account will use. The key is computed idempotently (a payload id already prefixed with the caller's own address is used as-is), so clients round-trip the returnedfact.idon forget/pin/retype with no change.It is a clean break: the new subgraph indexes V2 only, from its deploy block, with no legacy data source. Production is pre-launch, so every existing on-chain fact is our own test data; those rows drop out of the product when the relay repoints to V2, which is intentional.
Clients need no code change for the mechanism — the composite id is transparent to them, and they pick up the V2
data_edge_addressfrom/v1/billing/status, so chain-aware clients need no release. The exception is the hardcoded fallback address baked into the Python client and the ZeroClaw Rust crate, which need a follow-up release.Warning
Not deployed. The V2 contract address and start block in the manifests are placeholders; the subgraph protects nothing until the contract is deployed and the staging exploit-replay E2E passes.
Verification
The vulnerability was reproduced on staging (Gnosis chain 100), DataEdge
0xE7a4D2677B686e13775Ba9092631089e35F0BB91, fact idaudit-11-bb3eadb2:0x24039B90C7Dacda99e8935C7C423112dCedDe7C3) wrote the fact — tx0xeac1688cb12475b7b876cb3108a71d008fa8d93c7a15538fd0ad13da8304da550xE8020eb0fa58828C35d33242FBf1E1AC8c36dC8E, an unrelated wallet) tombstoned it,isActive → false— tx0x3a8f551f27e38ddfa67255b2a233d62bb325744402f93471664a7ecf59519c46ownerto itself — tx0x73ee61d9fc2da7bdab1fe980a62cb44e0a035393f6cfdcd9018c76d0669be2a2Other checks:
contracts: 41 forge tests pass, including 5 newEventfulDataEdgeV2tests (sender == caller, distinct senders for the same payload, permissionless append,receive()emits nothing).subgraph:graph codegen+graph buildpass for the default, mainnet and staging manifests (V2-only, a single data source into one entity store).Checklist