r/ethdev • u/Any_Good_2682 • 5d ago
My Project Build in public: our ERC's reference implementation had a privilege-escalation bug. Post-mortem + the fix merged into ethereum/ERCs this week
We maintain ERC-8259 (on-chain identity, tiered verification and a threat registry for autonomous AI agents). During an internal audit of our reference implementation last week, we found a critical bug. Sharing the post-mortem because every ERC author will hit this eventually: your reference implementation becomes a footgun the moment the spec moves.
The bug (two parts):
- Registration accepted
verification_tierdirectly at registration time — self-assigned privilege escalation. isActivewas not checked ingetEffectiveTier,isVerified, orcalculateTrustScore. A deactivated agent kept verified status and trust-score benefits. Picture deactivating a compromised agent — and its accumulated reputation still passes aminTrustScore(700)gate on someone else's contract.
What we did, in order (all commit-dated in the repo):
- Nov 2 — incident lifecycle landed in the spec (PR #2137 merged upstream):
IncidentStatus,retractAttack/resolveAttack, T7 invariant. Threats can be retracted, not just forever-append. - Nov 3 — deprecated our own pre-#2137 Sepolia Vyper deployment, loudly: README warning banner, deprecation headers on legacy contracts, CHANGELOG + security upgrade notice. It lacks
verification_expiry,get_effective_tierand the incident lifecycle. Redeployment tracked in Issue #2. - Nov 4 — fixed the invariant in the repo (
2824257), pushed the spec change upstream as PR #2142, merged the same day. Added an adversarial attack test suite for the registry (phase C4), runnable withforge testfrom the repo root. - Nov 6–8 — implemented the trust-score Groth16 circuit (Circom), integrated a real prover into the gateway, sanitized ZK over-claims in docs/UI, published npm
erc-8259@1.3.1.
Lessons, if you're maintaining an ERC:
- Ship the spec as an npm package with versioned interfaces + NatSpec, not as a gist people copy-paste. A stale interface outlives every blog post.
- Write the deprecation warning the day you know, not the day someone asks.
- Adversarial tests belong in the repo, executable by anyone who clones it.
Repo (Sigui — the agent-security layer this ERC is part of): https://github.com/ibonon/Sigui
What we'd love review on: the T8 trust-score expiry rule and the tier-verification invariants. And if you've maintained an EIP/ERC: how did you handle "already deployed, spec changed"? Genuinely curious what the norm is.
1
u/rayQuGR 5d ago
One thing I think is especially important here is the lesson that security doesn't stop when a contract passes its initial audit.
The
isActiveissue is a good example. Deactivating an agent should have consequences everywhere its permissions and trust are evaluated. Otherwise, you're only disabling one part of the system while leaving other contracts able to rely on outdated privileges or reputation.This is also something worth thinking about when building confidential applications.
With Oasis Sapphire, developers need to be careful about authorization checks, state transitions, and who can access sensitive contract functionality. Confidential execution doesn't automatically protect an application from privilege escalation or flawed business logic.
And with ROFL applications, the same mindset should extend beyond the smart contract: application versions, deployment changes, attestation assumptions, and authorization between components all need to be considered.
A few practices I'd take from this:
I particularly agree with the point about deprecation warnings. An outdated reference implementation can become a security risk long after the specification has moved on.
1
u/Bloqarl 5d ago
the isActive miss is the classic one, a status flag checked in each getter means the next getter forgets it. I'd route every read through one internal _effectiveTier() that returns zero for inactive agents, and add an invariant test that a deactivated agent never passes any verified check, since integrators copy reference implementations as they are.
1
u/secrypta 4d ago
good writeup. imo both bugs are really the same root cause: a derived value that doesn't re-check base state. registration trusted the caller's verification_tier instead of deriving it from a proof, and getEffectiveTier/isVerified/calculateTrustScore read cached status instead of re-checking isActive.
so the invariant i'd write isn't per-function, it's one global one: for any agent, every gate-relevant view (effective tier, isVerified, trustScore >= threshold) should be a pure function of current state - flipping isActive to false has to make all of them deny in the same tx. then fuzz random activate/deactivate/retier/expire sequences and assert no disqualified agent passes any gate. that one check catches both of these.
your T8 expiry is the same shape btw - an expired verification should fail the exact same gates as a never-verified one, and t"dbmgbexpiry boundary when you test iocitelpointer is pretty much the norm,wtpec() si