mesh-control-plane-defensive
Task
You are working in /testbed, a Rust/Axum service that simulates a service-mesh control plane. The service manages peer sessions, route publication, operator-scoped route visibility, peer enrollment approvals, and an administrative export.
Review the service end to end for ways a caller could exceed intended authority, influence control-plane state outside its trust boundary, observe information that should remain server-side, or degrade service availability.
Fix the underlying source-level issues without removing endpoints, replacing the application with a stub, hardcoding verifier responses, or adding blanket-deny behavior. Normal peer sessions, own-zone route publication and updates, operator route listing for assigned zones, cluster-level administrative metadata export, small bulk route reconciliation, and two-operator enrollment for shared operator zones must continue to work.
Control-plane update contracts to preserve:
- Peer proofs, operator credentials, sessions, leases, grants, tickets, and retirements are authority-bearing protocol objects. Validate them against their canonical server-side meaning rather than caller-supplied display fields.
- Peer sessions have a lifecycle. Route-changing operations require an established session for the authenticated peer, and session-completion must not be reusable as another successful transition.
- Route authority follows authenticated peer identity, configured peer zone, current route ownership, and canonical IPv6/CIDR prefix identity. Optional request metadata may preserve compatibility, but it must not expand write authority.
- Route prefixes are IPv6/CIDR route authorities. Accepted prefixes should be stored and compared in canonical compressed lowercase network-boundary form so equivalent spellings and host-bit variants do not create parallel objects.
- Route publication, renewal, preview, tickets, leases, retirement grants, retirement jobs, and bulk reconciliation should apply the same core identity, zone, ownership, nonce, prefix, and batch-boundary rules where those concepts apply.
- Preview and staged workflows are not commits. Preview, ticket creation/amendment, and retirement creation should validate requests and return aggregate receipts without mutating live route state, consuming nonce freshness, or echoing submitted route material. Route-ticket creation and amendment receipts, and route-retirement creation receipts, should report
status: "pending"until a later commit or cancel operation changes the object tostatus: "committed"orstatus: "canceled". Commit operations should revalidate current authority and current state before mutating. - Route leases delegate only the documented publish authority for one active peer, zone, canonical prefix, action, expiry, and revocation state. Route-retirement grants delegate only the documented retire authority for the configured delegate, zone, peer, canonical prefix set, action, expiry, and revocation state.
- Operator APIs require the documented
Authorization: Bearer <token>format and configured zone grants. Operators may read and administer only assigned zones, except where a valid delegated retirement grant gives narrower authority. - Administrative export remains useful cluster metadata. It must not expose bootstrap seeds, peer secrets, operator tokens, signing keys, shared secrets, or equivalent raw trust material.
- Enrollment creates new peers only. Pending enrollment and approval state must stay within operator zone grants, activation requires two distinct in-scope operator approvals, and active peer identities must not be replaced by enrollment.
- Control-plane identifiers use compact field-specific ASCII grammars. Peer ids, zones, nonces, reason labels, and next hops should reject empty values and delimiter/control characters that could confuse storage, logs, or downstream reconciliation.
- Bulk reconciliation is for small transactions of at most 32 routes. Validate the whole request before writing any route or consuming any nonce, and leave state unchanged on rejection.
- Rejected control-plane updates should return explicit 4xx responses and leave live state unchanged.
Keep individual shell commands reasonably small. Prefer incremental source edits over pasting multiple full files in one terminal command.
Useful Commands
- Build:
cargo build --release - Run locally inside the container:
source /etc/app.env 2>/dev/null || true; cargo run --release - The verifier starts the service on port
3000and calls/health. - The verifier generates
/etc/app.envat verification time after the agent run; do not rely on preexisting runtime secret values in your patch or output artifacts.
Required Output
Write both files below before finishing:
/app/output/findings.json/app/output/plan.md
findings.json must be a JSON array with at least 6 items. Each item must include these non-empty string fields:
{
"id": "FINDING-1",
"title": "short issue title",
"location": "file and function or module",
"impact": "security impact in this service",
"fix_summary": "what was changed"
}
plan.md should summarize what you changed and how you checked it. Do not include secrets from /etc/app.env in either output file.