Repository navigation
fix(deployments): revoke pool admission and Portal roles from replaced routers #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,12 +11,14 @@ import { engineDefinitions, inspectEngineBindings } from '../modules/earn/engine | |
| import { | ||
| capabilityModules, | ||
| deploymentStep, | ||
| deploymentSteps, | ||
| executeAvailableAuthority, | ||
| } from '../../deployments/modules/index.js' | ||
| import type { | ||
| DiscoveryOptions, | ||
| InspectionReport, | ||
| PrivilegedPrincipal, | ||
| import { | ||
| retiredOutputKey, | ||
| type DiscoveryOptions, | ||
| type InspectionReport, | ||
| type PrivilegedPrincipal, | ||
| } from '../../deployments/modules/module.js' | ||
| import { | ||
| assertFoundryVersion, | ||
|
|
@@ -183,13 +185,9 @@ async function deployEarnProfileLocked(options: LifecycleOptions): Promise<EarnD | |
| : new Set<IntentComponent>() | ||
| for (const component of replaced) reconciling.add(component) | ||
| // A paused replacement may itself predate this checkout's build, so cached contracts are checked too. | ||
| const cached = cachedPendingOutputs(options.profilePath, profile) | ||
| const staleCached = committed | ||
| ? await replacedComponents( | ||
| client, | ||
| profile, | ||
| { addresses: cachedPendingOutputs(options.profilePath, profile) }, | ||
| compile, | ||
| ) | ||
| ? await replacedComponents(client, profile, { addresses: cached }, compile) | ||
| : new Set<IntentComponent>() | ||
| syncFoundryOutputs(options.root, options.profilePath) | ||
| let pending: PendingDeployment | ||
|
|
@@ -213,6 +211,12 @@ async function deployEarnProfileLocked(options: LifecycleOptions): Promise<EarnD | |
| replaced, | ||
| staleCached, | ||
| ) | ||
| // Replaced contracts keep what activation granted them until the revoke steps remove it. | ||
| const retired = retiredContracts(committed.addresses, reconciling, cached, staleCached) | ||
| if (Object.keys(retired).length > 0) { | ||
| pending = { ...pending, outputs: { ...pending.outputs, ...retired } } | ||
| savePendingDeployment(options.profilePath, profile, pending) | ||
| } | ||
|
Comment on lines
+214
to
+219
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Low (trigger unconfirmed) · unverified: Retired-router revocation obligation lives only in ephemeral pending state; losing it marks… Mechanism: when a router is replaced, deployEarnProfile records the old address under Full findingRetired-router revocation obligation lives only in ephemeral pending state; losing it marks the profile complete while the replaced router keeps pool and Portal roles Mechanism: when a router is replaced, deployEarnProfile records the old address under How the obligation is lost: In each case, retiredOutputs(outputs, 'earnRouter' | 'zoneRouter') returns []. poolRoutersRevoked and portalRoutersRevoked return true for the empty list (earn/zone-router/steps.ts:269-276, 341-350), so all four revoke steps are satisfied. The deploy reaches 'complete', calls removePendingDeployment, and reports success. Impact: the replaced router still holds PropAMM taker/recipient admission and Portal callback-gateway and allowed-account roles. Two privileged routers stay live, which is the condition this PR exists to remove. The lifecycle also gives a false 'complete' signal, so nobody is prompted to revoke. Preconditions: a router replacement whose revoke handoff does not land in the same run, followed by loss or discard of deployment.pending.json before the authority acts. Missing evidence: GitHub cache retention for this repository and the real authority turnaround times. Whether the old router's leftover roles are exploitable depends on that contract's code; at minimum, it remains a privileged admitted taker/recipient and gateway. Remediation: persist the retired set durably. Options: write retired addresses into the published deployment record, or a committed sidecar, until revocation is verified. Or derive retired routers from on-chain or record history, such as previous records' router addresses or role-grant events. Do not let an empty pending-derived list satisfy the revoke steps. At least, have restorePendingDeployment carry Valid? React with 👍 / 👎.
Comment on lines
+214
to
+219
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Medium (trigger unconfirmed) · unverified: Publishing a replacement can strand revocations in disposable resume state Once a replacement is published, unfinished revocations must remain discoverable on subsequent deploys. The command saves the predecessor only in pending outputs, publishes the successor before activation, and excludes the predecessor and cleanup obligations from the published record. Full findingOnce a replacement is published, unfinished revocations must remain discoverable on subsequent deploys. The command saves the predecessor only in pending outputs, publishes the successor before activation, and excludes the predecessor and cleanup obligations from the published record. If revocation then requires a handoff and the pending file is absent on the next run, or a later periphery edit invalidates its intent hash, restore starts without the predecessor. The new record contains only the successor, so retirement detection cannot reconstruct the missing obligation. An empty retirement list satisfies cleanup, allowing complete while old grants remain. This can occur without an attacker; the workflow handles the pending cache and published record separately. No actual cache miss or affected live deployment was established. Persist unresolved retirements in durable, verified state before publishing the successor, carry them across allowed intent changes, and remove them only after checking the historical grants onchain. Valid? React with 👍 / 👎. |
||
| } else { | ||
| pending = loadPendingDeployment(options.profilePath, profile) | ||
| } | ||
|
|
@@ -776,6 +780,30 @@ export function publicFixtureAddresses() { | |
| ) | ||
| } | ||
|
|
||
| /** | ||
| * The pending-output entries for granted contracts this deployment redeploys, whether its intent or its | ||
| * code changed: the recorded ones, and stale cached replacements. | ||
| */ | ||
| function retiredContracts( | ||
| recorded: DeploymentAddresses, | ||
| reconciling: ReadonlySet<IntentComponent>, | ||
| cached: DeploymentAddresses, | ||
| staleCached: ReadonlySet<IntentComponent>, | ||
| ) { | ||
| const retired: Record<string, Address> = {} | ||
| for (const step of deploymentSteps) { | ||
| if (step.execution !== 'foundry' || !step.source?.retireOnReplace) continue | ||
| const { output } = step.source | ||
| const previous = [ | ||
| step.intent.some((component) => reconciling.has(component)) ? recorded[output] : undefined, | ||
| step.intent.some((component) => staleCached.has(component)) ? cached[output] : undefined, | ||
| ] | ||
| for (const address of previous) | ||
| if (address) retired[retiredOutputKey(output, address)] = address | ||
|
Comment on lines
+797
to
+802
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Low (exposure and trigger unconfirmed) · unverified: Retirement checks the successor's grant targets instead of the predecessor's Retirement must remove grants where they were issued. The new journal stores only the router address, while both router implementations use the successor's configured pool and discovered Portal for verification, writes, and handoffs. Same-chain target changes are expressly allowed during reconciliation. Full findingRetirement must remove grants where they were issued. The new journal stores only the router address, while both router implementations use the successor's configured pool and discovered Portal for verification, writes, and handoffs. Same-chain target changes are expressly allowed during reconciliation. For example, if router A was admitted on pool P and its successor uses pool Q, the check can find no permission for A on Q and report success while both flags remain on P. If the successor has no conversion pool, the step is disabled instead. A Zone move has the same problem for roles on the old Portal. Deployment can therefore report complete with the predecessor still authorized on its former infrastructure. This needs a supported profile migration and a previously granted router, not an attacker prerequisite; no affected live migration was established. Persist the original chain, pool, Portal, and Zone identity for each retirement before replacing the record, and verify and route revocations against those historical targets. Valid? React with 👍 / 👎. |
||
| } | ||
| return retired | ||
| } | ||
|
|
||
| /** The contracts a resumable pending file holds, or none when there is no usable one. */ | ||
| function cachedPendingOutputs(profilePath: string, profile: EarnDeploymentProfile) { | ||
| try { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟣 pre-existing, not blocking: A replaced router can keep its pool admission and Portal roles while deploy reports
complete, once the gitignored pending file is lost or reset. The retired addresses live only indeployment.pending.json, but the record pointing at the successor is published before activation runs. Fix: keep the retired addresses in durable state, such as the published record or something derived from record history, so later runs andverifystill see them; or hold back publishing the successor record until both revoke steps are satisfied.A small fix can ride a push you are already making; otherwise a short reply is enough.
Why this was flagged
The retired entries are written only into pending outputs (deploy.ts:215-218). buildDeploymentRecord leaves them out of the record, and publishProfileDeploymentRecord (deploy.ts:302) commits the successor router before the activation loop (deploy.ts:343). Suppose a revoke step hands off and the operator resumes from another checkout or CI (pending is gitignored as
**/deployment.pending.json). Or suppose the profile is edited and loadPendingDeployment throws on the intent-hash check, which restorePendingDeployment swallows at pending.ts:184-186 and then overwrites. Either way the committed record already has the new router, soreplacedis empty and retiredContracts returns nothing. revokeRetired*Pool/Gateway then seeretiredOutputs(...)as [] and report satisfied, and deploy returnscompletewhile the old router stays a pool taker/recipient and Portal gateway. The verify path (reconcile.ts:476) checks record addresses only, so it also misses the leftover authority.Verification: The base never revoked anything. Trigger: a run publishes the successor record and then stops at an activation handoff, and on the next run the pending file is missing or cannot be loaded. The retired addresses exist only in pending outputs (deploy.ts:215-218).
poolRoutersRevokedandportalRoutersRevokedcall.everyon an empty list, which is true. The deploy endscomplete.