fix(security): Enforce fail-closed for empty admin token (#425)#691
Merged
santoshkumarradha merged 1 commit intoJun 27, 2026
Merged
Conversation
Contributor
📊 Coverage gateThresholds from
✅ Gate passedNo surface regressed past the allowed threshold and the aggregate stayed above the floor. |
Contributor
📐 Patch coverage gateThreshold: 80% on lines this PR touches vs
✅ Patch gate passedEvery surface whose lines were touched by this PR has patch coverage at or above the threshold. |
santoshkumarradha
approved these changes
Jun 27, 2026
santoshkumarradha
left a comment
Member
There was a problem hiding this comment.
Checked the auth/config path locally. The fail-closed behavior and explicit insecure escape hatch both look right, and the focused Go tests passed on my side.
AbirAbbas
added a commit
that referenced
this pull request
Jun 27, 2026
3 tasks
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the issue where an empty admin token silently disabled route protection.
internal/server/middleware/auth.go: AddedValidateAdminTokenAuthand updatedAdminTokenAuthmiddleware to return 401 instead of letting requests through when no token is set.internal/config/config.go: AddedInsecureDisableAdminAuthfield to configuration and mapped theAGENTFIELD_INSECURE_ADMIN_NO_TOKENenv var.internal/server/server.go: Added startup validation that stops the server from launching if the admin token is missing, unless insecure mode is explicitly configured.internal/server/routes_admin.go: Updated route registration to pass the new config structure to the middleware.tests: Added and updated unit tests to verify the new startup validations, env override flags, and 401/403 responses.Type of change
Test plan
Run the following test commands locally to verify the new startup validations, the middleware's fail-closed unauthorized/forbidden assertions, and configuration override behavior:
cd control-plane && go test -v ./internal/server/...cd control-plane && go test -v ./internal/server/middleware/...cd control-plane && go test -v ./internal/config/...Test coverage
Before asking for review, please confirm:
coverage-baseline.jsonin this PR only if the removal caused a legitimate regression and I called it out in the summary above.Checklist
Related issues / PRs
Closes #425