Skip to content

fix(queue): refuse broker credentials over plaintext amqp:// - #99

Merged
M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/refuse-plaintext-amqp-credentials
Nov 11, 2026
Merged

M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/refuse-plaintext-amqp-credentials

Conversation

@M3gA-Mind

Copy link
Copy Markdown
Collaborator

Summary

RabbitQueues::connect and the facade's QueueConfig::parse accepted any amqp:// URL, so a host that forgot its own check could send broker credentials in clear text. Both now apply one rule, tinystoragedrivers_queue::check_broker_url:

  • amqp:// with userinfo is refused (InvalidInput) unless the host is loopback (localhost, 127.0.0.0/8, ::1) or the URL opts in with ?insecure=true for a trusted private network.
  • amqps://, loopback, and credential-free URLs pass unchanged.
  • Every insecure parameter is removed before connecting, so the opt-in never reaches the broker.
  • The error message never contains the URL or its credentials.

QueueConfig::parse keeps the URL as given; connect checks it again and strips the opt-in. Hosts may apply a stricter rule. OpenHuman's own guard (inbound/settings.rs) also refuses loopback and keeps doing so.

Closes #79

API or behavior changes

New public function tinystoragedrivers_queue::check_broker_url. Behaviour: a non-loopback amqp:// URL with credentials and no opt-in is now refused at parse and at connect.

Validation

On a Linux build host, merged onto main 05acdd9 (and merging cleanly onto v2.1.3, f5a3302):

  • cargo test --locked -p tinystoragedrivers-queue --features rabbitmq broker_url: 4 passed.
  • cargo test --locked -p tinystoragedrivers --features rabbitmq queues: 4 passed.
  • cargo check --locked -p tinystoragedrivers --no-default-features, and with --features rabbitmq.
  • cargo test --workspace --all-features --locked: 856 passed, 0 failed, 1 ignored.
  • clippy -D warnings (0 items), cargo fmt --check, rustdoc -D warnings.
  • The live RabbitMQ suite was not run there: no broker on the host. CI's RabbitMQ job runs it, and its TSD_RABBITMQ_URL (amqp://guest:guest@127.0.0.1…) is loopback, so it is allowed.

Tests

  • rabbitmq/broker_url_tests.rs:
    • plaintext credentials to a remote host are refused without echoing them (including IPv6, uppercase scheme, username-only, and insecure=false);
    • TLS, loopback and credential-free URLs pass unchanged;
    • the opt-in allows plaintext and is stripped, with other query parameters and the fragment preserved;
    • other schemes are left to the connection.
  • queues_tests.rs: the facade refuses, allows and keeps the opt-in on the parsed URL.
  • Spec: docs/specs/queue-rabbitmq.md documents the rule.

RabbitQueues::connect and the facade's QueueConfig::parse accepted any
amqp:// URL, so a host that forgot its own check could send broker
credentials in clear text. Both now apply check_broker_url: an amqp://
URL with userinfo needs a loopback host (localhost, 127.0.0.0/8, ::1) or
the explicit opt-in ?insecure=true for a trusted private network.
amqps:// and credential-free URLs are unaffected. The opt-in is removed
before connecting, so it never reaches the broker, and the error never
contains the URL. Hosts may keep a stricter rule of their own.

Closes tinyhumansai#79
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0e9936c4-8386-4ced-bcd4-5ef456096c32
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@tinysweeper

tinysweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

Reviewed head: 4e26639426e04b4101025698a85b59a8a74a2d25

Findings

No active actionable findings.

Advisory notes

  • medium: Pin the URL guard inside RabbitQueues::connect with a test (crates/tinystoragedrivers-queue/src/rabbitmq/queues.rs:110)
    Problem: The new doc on `connect` states: "`InvalidInput` when the URL sends credentials in clear text without opting in." Nothing in the diff pins that claim. `broker_url_tests.rs` exercis
    Suggested fix:
    No concrete fix was supplied.

Verdict: Ready for maintainer review · Priority: medium
Coverage: Reviewed 8 of 8 files.

Diagnostics and supporting details

Full summary

Pull request purpose (title): fix(queue): refuse broker credentials over plaintext amqp://. `QueueConfig::parse` keeps the URL as given while `connect` re-checks and strips the opt-in. No push delta is available: the review state has no trusted base-to-head comparison, so only the whole-pull-request behavior is described.

Review snapshot

Change surface Files Review signal Count
Production 5 Active findings 0
Tests 2 Noted findings 1
Documentation 1 Resolved findings 0
Configuration 0 Pending checks/questions 0

Completeness: Complete
Test assessment: No supported feature-to-test mapping was available; this does not mean tests are absent or passed.

What changed

Both enforcement points now share one rule. `RabbitQueues::connect` calls the check first and opens the link with the returned, opt-in-free URL, so a refused URL never reaches the connection. `QueueConfig::parse` calls the same check before constructing the `RabbitMq` variant but stores the URL as given, deferring stripping to connect. The function is exported from the queue crate and documented in the RabbitMQ spec, including that hosts may apply a stricter rule.

Features

  • Added — Shared plaintext-credential rule for broker URLs (`check_broker_url`): A single exported predicate distinguishes `amqps://`, loopback (`localhost`, `127.0.0.0/8`, `::1`) and credential-free URLs, which pass unchanged, from plaintext `amqp://` URLs with userinfo to a remote host, which fail with `InvalidInput`; the opt-in parameter is stripped from the returned URL and the error text names neither the URL nor its credentials. (crates/tinystoragedrivers-queue/src/rabbitmq/broker_url.rs, crates/tinystoragedrivers-queue/src/lib.rs)
  • Modified — `RabbitQueues::connect` enforces the rule and connects with the stripped URL: The enforcement point that protects a live connection: a URL failing the rule is rejected before the link is opened, and a URL that opts in is passed to the link with every `insecure` parameter removed, so the opt-in never reaches the broker; the documented `InvalidInput` contract on `connect` states the message contains no URL. (crates/tinystoragedrivers-queue/src/rabbitmq/queues.rs impl RabbitQueues {)
  • Modified — `QueueConfig::parse` refuses plaintext credentials at configuration time: Configuration is rejected early with `InvalidInput` for a non-loopback `amqp://` URL with credentials and no opt-in, while the parsed `RabbitMq` variant keeps the URL exactly as supplied (opt-in included) so stripping remains the queue port's job at connect. (crates/tinystoragedrivers/src/queues.rs impl QueueConfig {, crates/tinystoragedrivers/src/queues.rs pub enum QueueConfig {)
  • Added — Specification of the plaintext-credential rule: The RabbitMQ spec records that both `QueueConfig::parse` and `RabbitQueues::connect` apply `check_broker_url`, what the loopback and opt-in exceptions are, that `amqps://` and credential-free URLs are unaffected, that the opt-in never reaches the broker, that errors carry no URL, and that hosts may apply a stricter rule. (docs/specs/queue-rabbitmq.md a new `Storage` bundle with its queue port replaced by a scope-bound)

Tests

No supported feature-to-test mapping was produced. Test execution is not inferred.

Before merge

None.

Agent review details

critique

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: Reviewed 8 files; 0 findings. _The code index is behind this pull request (indexed at `59be10fc03cc`), so retrieved context may be out of date._

security

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: Reviewed 7 files; 0 findings. 1 file was not security-reviewed: docs/specs/queue-rabbitmq.md (prose or tabular data). _The code index is behind this pull request (indexed at `59be10fc03cc`), so retrieved context may be out of date._

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The tests lane answered with no findings, noting that the helper's behaviour and the `QueueConfig::parse` enforcement are well pinned by the added unit and facade tests.
  • Positive: The same answered lane flagged that `RabbitQueues::connect` — the enforcement point that actually guards a live connection — has no test that would fail if the call were dropped or moved.
  • Lane summary: The change adds a plaintext-credential rule for AMQP broker URLs, wires it into both `QueueConfig::parse` and `RabbitQueues::connect`, and adds unit tests for the helper plus a facade test for `parse`. The helper's behaviour and the `parse` enforcement are well pinned, but the enforcement point that actually protects a live connection — `RabbitQueues::connect` — has no test that would fail if the call were dropped or moved, so the stated `InvalidInput` contract on `connect` is unverified. _The code index is behind this pull request (indexed at `59be10fc03cc`), so retrieved context may be out of date._

commits

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The commits lane answered with no sensitive content in committed files; nothing in the changed paths commits credentials.
  • Lane summary: No sensitive content in committed files. _The code index is behind this pull request (indexed at `59be10fc03cc`), so retrieved context may be out of date._

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The description lane answered with no findings: the description matches the change — helper added and exported, applied in `connect` with the opt-in stripped before connecting, applied in `QueueConfig::parse`, with the stated loopback/`amqps://`/opt-in rules, a credential-free error message, tests covering refusal, TLS, loopback, opt-in stripping and other schemes, plus the spec update, and no unreported significant behaviour in the diff.
  • Lane summary: The description matches the change: `check_broker_url` is added, exported from the queue crate, applied in `RabbitQueues::connect` (with the `insecure` opt-in stripped before connecting) and in the facade's `QueueConfig::parse`, with the stated loopback/`amqps://`/opt-in rules, a credential-free error message, sibling `*_tests.rs` tests covering refusal, TLS, loopback, opt-in stripping and other schemes, plus the spec update. I found no behaviour the description claims that the diff does not implement, and no unreported significant behaviour in the diff. _The code index is behind this pull request (indexed at `59be10fc03cc`), so retrieved context may be out of date._
Evidence and run details
  • Models: ladder/vectors-oai3, deepseek-v4.1-flash, deepseek-v4-flash
  • Spend: $0.035780
  • Completion usage: incomplete; some provider completion costs are unavailable.
  • Tokens: 790409 input · 143798 output · 354686 cached · 492 embedding
  • Updated: 2026-11-11T12:12:09Z
Head State Pass summary
4e26639426e0 ready for maintainer review 0 active finding(s), 0 resolved finding(s) (at 2026-11-11T12:12:09Z)

tinysweeper 0.1.2

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tinysweeper found nothing blocking. Approving.

Diagnostics

Total spend: $0.0358

@M3gA-Mind
M3gA-Mind merged commit 9630ae3 into tinyhumansai:main Nov 11, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refuse plaintext broker credentials in the RabbitMQ driver

1 participant