Skip to content

Add negative-auth canary tests for the internal loopback backend#17023

Open
lukebakken wants to merge 1 commit into
rabbitmq:mainfrom
amazon-mq:add-internal-loopback-auth-canary-tests
Open

Add negative-auth canary tests for the internal loopback backend#17023
lukebakken wants to merge 1 commit into
rabbitmq:mainfrom
amazon-mq:add-internal-loopback-auth-canary-tests

Conversation

@lukebakken

Copy link
Copy Markdown
Collaborator

What

The internal loopback authN backend's user_login_authentication/2 has several fail-closed branches, but the existing suite only exercised the positive login paths and the is_loopback=false gate. Both pre-existing "refused" cases refused on the address gate before ever reaching password verification, so the salted-hash comparison, the blank-password rejection, and the fail-closed default when no socket or address is provided had no coverage.

This change adds four negative-auth canaries to the localhost_connection group, each asserting the specific refusal message so a regression that short-circuits on the wrong branch is caught (the pre-existing cases used a wildcard for the message):

  • wrong password is refused with invalid credentials
  • blank password is refused
  • unknown user is refused with invalid credentials
  • missing socket/address info fails closed

Why

These branches are the security-critical part of the backend: they are what keeps a loopback connection from authenticating without valid credentials. A future change that made any of them fail open would be silent today because nothing asserts on them. Asserting on the exact refusal reason (rather than just "some refusal happened") ensures each test proves the branch it is meant to guard actually fired.

Scope

Test-only. No production code changes. The new cases pass against the current implementation.

Testing

Ran the suite locally:

gmake -C deps/rabbitmq_auth_backend_internal_loopback ct-rabbit_auth_backend_internal_loopback

Result: 8 Ok, 0 Failed, 0 Skipped (4 pre-existing plus the 4 new canaries).

The internal loopback authN backend's user_login_authentication/2 has
several fail-closed branches, but the existing suite only exercised the
positive login paths and the is_loopback=false gate. The two "refused"
cases refused on the address gate before ever reaching password
verification, so the salted-hash comparison, blank-password rejection,
and the fail-closed default when no socket or address is provided had no
coverage.

Add four canaries in the localhost_connection group, each asserting the
specific refusal message so a regression that short-circuits on the
wrong branch is caught:

  - wrong password is refused with invalid credentials
  - blank password is refused
  - unknown user is refused with invalid credentials
  - missing socket/address info fails closed

These are test-only additions and pass against the current
implementation.
@mergify

mergify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant