You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(broker): a reload deny of a login writes two denied entries #220
When a reload of the config takes away the client or its pin while a login request (or a login pre-approval) waits for the fetch after the tap, the broker writes twodenied entries (cause not_allowed) for the one request:
stillAllowedLogin → the reload check writes Denied and answers 403;
then the caller (handOutLogin or preapproveLogin in internal/broker/logins.go) writes a second Denied with the same subject. Its answer is ignored, because the request has already answered.
Found by the security review of #219 (#205). The test TestLoginPreapproveClearsBeforeTheAnswer/denied:_a_reload_took_the_pin_away_during_the_fetch shows it: the events are request decision:approve_once config_reloaded denied:not_allowed denied:not_allowed.
It does not fail open: the request is denied. But a request should have one end entry, and a reader of the audit log may be confused.
Done when
A reload deny on the login paths writes one denied entry (for example: the caller writes its own entry only when sameLogin or the rule check failed, not after the reload deny).
A test for handOutLogin and for preapproveLogin checks that the request has exactly one denied entry after a reload that takes the pin away.
stillAllowedLogin now returns (ok, answered). The callers handOutLogin and preapproveLogin use a new helper loginStillSame. They write their own denied entry only when the reload check has not already answered. Who is denied does not change: ok is true only when both checks pass, as before.
Evidence for each "Done when" box:
A reload deny on the login paths writes one denied entry. The fix is in internal/broker/logins.go. Without the fix, the "pin is taken away" cases below fail with denied:not_allowed denied:not_allowed. With the fix, they pass.
A test for handOutLogin and for preapproveLogin. The test is TestLoginReloadDenyOneEntry in internal/broker/reloaddeny_test.go. It runs a reload during the fetch after the tap, for a login and for a login pre-approval, in three cases:
the pin is taken away;
the rule changed;
the clients changed.
Each case checks four things:
the answer is 403;
the entries of the request are exactly request decision:approve_once denied:not_allowed;
no login is kept and no grant starts;
the values are cleared.
The existing deny-path tests still pass. That includes TestLoginPreapproveClearsBeforeTheAnswer.
Activity
groupsky commentedon Nov 19, 2026
hq-jobs
nodkey-220-build(runr-20261119-110019-9b4f)Fixed in #222 (squash commit 5ee093c).
stillAllowedLoginnow returns(ok, answered). The callershandOutLoginandpreapproveLoginuse a new helperloginStillSame. They write their owndeniedentry only when the reload check has not already answered. Who is denied does not change:okis true only when both checks pass, as before.Evidence for each "Done when" box:
A reload deny on the login paths writes one
deniedentry. The fix is ininternal/broker/logins.go. Without the fix, the "pin is taken away" cases below fail withdenied:not_allowed denied:not_allowed. With the fix, they pass.A test for
handOutLoginand forpreapproveLogin. The test isTestLoginReloadDenyOneEntryininternal/broker/reloaddeny_test.go. It runs a reload during the fetch after the tap, for a login and for a login pre-approval, in three cases:Each case checks four things:
request decision:approve_once denied:not_allowed;The existing deny-path tests still pass. That includes
TestLoginPreapproveClearsBeforeTheAnswer.CI run: https://github.com/code6x/nodkey/actions/runs/44493201327 (tests, lint, e2e, vuln, ansible role). The title check passed too: https://github.com/code6x/nodkey/actions/runs/44493811683
The security review found one low gap: the tests did not reach the clients check. I added the "clients changed" cases to cover it. No finding is open.