HTTP API: GET /api/queues/{vhost} requests logs a debug message saying that access to certain virtual hosts is prohibited #14923
-
Describe the bugWhen calling /api/queues/myvhost for a specific vhost myvhost, RabbitMQ attempts to access all other existing vhosts. If the user does not have permissions on those vhosts, the following error occurs:
Expected behavior: Actual behavior:
Reproduction steps
Expected behaviorThe API should only query the requested vhost (myvhost). Other vhosts must not be accessed. Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
|
@clude86 it's not uncommon for various API endpoints to filter virtual hosts accessible to the user. You haven't provided any evidence or steps to reproduce. Not even what RabbitMQ version is used. We do not guess in this communities. |
Beta Was this translation helpful? Give feedback.
-
|
Here is the API handler module in question. Indeed, it filters out what virtual hosts are available to the user because the same endpoint handles The message in question is a For any meaningful further investigation we need
A |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your reply! You’re right — my initial description was too abstract. Environment: Reproduction Example (Docker)
services:
rabbit:
image: rabbitmq:4.1.5-management
container_name: rabbit-api-repro
environment:
RABBITMQ_DEFAULT_USER: admin
RABBITMQ_DEFAULT_PASS: admin
RABBITMQ_LOGS: "-"
ports:
- "15672:15672"
- "5672:5672"
docker compose up -dWait until the broker is ready: docker logs -f rabbit-api-repro
docker exec -it rabbit-api-repro rabbitmqctl set_log_level debug
# Create vhosts
curl -u admin:admin -X PUT http://localhost:15672/api/vhosts/%2F
curl -u admin:admin -X PUT http://localhost:15672/api/vhosts/myvhost
curl -u admin:admin -X PUT http://localhost:15672/api/vhosts/othervhost
# Create a user with management access (so it can use the HTTP API)
curl -u admin:admin -X PUT http://localhost:15672/api/users/myuser \
-H "Content-Type: application/json" \
-d '{"password":"mypass","tags":"management"}'
# Grant permissions only on myvhost
curl -u admin:admin -X PUT http://localhost:15672/api/permissions/myvhost/myuser \
-H "Content-Type: application/json" \
-d '{"configure":".*","write":".*","read":".*"}'
curl -u myuser:mypass -X PUT http://localhost:15672/api/queues/myvhost/testqueue \
-H "Content-Type: application/json" \
-d '{}'
curl -u myuser:mypass http://localhost:15672/api/queues/myvhostIn the RabbitMQ logs (docker logs rabbit-api-repro), with debug logging enabled, you will see: This happens even though the request was only for /api/queues/myvhost. Expected Behavior
|
Beta Was this translation helpful? Give feedback.
-
|
Addressed by #14931 contributed by @lukebakken. Note that besides a tiny efficiency gain, there are no practical gains here for those who run with log severity levels starting with |
Beta Was this translation helpful? Give feedback.
Addressed by #14931 contributed by @lukebakken.
Note that besides a tiny efficiency gain, there are no practical gains here for those who run with log severity levels starting with
info(withoutdebuglogging enabled).