Admin API rejects invalid tokens with 303 instead of 401 status code #2015

Closed
opened 2026-04-06 02:49:20 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @linkvt on 8/27/2022

Hi,

first of all thanks for this nice project, I really appreciate it!

Subject of the issue

I was setting up fail2ban for my Vaultwarden instance and noticed, that on invalid tokens the Vaultwarden Admin API responds with a 303 HTTP status code instead of a 401 I usually see.

Deployment environment

I removed most of the fields as they are IMO irrelevant.

  • vaultwarden version: 1.25.2

Steps to reproduce

Try to log into the admin UI with an incorrect token.

Expected behaviour

HTTP response with 401 Unauthorized status code.

Actual behaviour

HTTP response with 303 See Other redirect status code.

Comment

Is this really intended from a behaviour perspective, see the implementation at
60ed5ff99d/src/api/admin.rs (L181)

If I understand the comment https://github.com/dani-garcia/vaultwarden/discussions/2448#discussioncomment-2666185 correctly it might be intended by you as the authors/contributors, but this is as far as I know not the correct behaviour for bad requests due to user issues (-> 4xx status code) due to failing authentication (narrowing to 401 Unauthorized).

While I understand the reasoning that a GET should follow the POST in this case, it does not make sense to me that a 303 is used.

Thanks for looking into this already!

Best, Vincent

P.S.: If you agree that this can be changed to a 401 I would be happy to open the PR myself.

*Originally created by @linkvt on 8/27/2022* <!-- # ### NOTE: Please update to the latest version of vaultwarden before reporting an issue! This saves you and us a lot of time and troubleshooting. See: * https://github.com/dani-garcia/vaultwarden/issues/1180 * https://github.com/dani-garcia/vaultwarden/wiki/Updating-the-vaultwarden-image # ### --> <!-- Please fill out the following template to make solving your problem easier and faster for us. This is only a guideline. If you think that parts are unnecessary for your issue, feel free to remove them. Remember to hide/redact personal or confidential information, such as passwords, IP addresses, and DNS names as appropriate. --> Hi, first of all thanks for this nice project, I really appreciate it! ### Subject of the issue I was setting up fail2ban for my Vaultwarden instance and noticed, that on invalid tokens the Vaultwarden Admin API responds with a 303 HTTP status code instead of a 401 I usually see. <!-- Describe your issue here. --> ### Deployment environment I removed most of the fields as they are IMO irrelevant. <!-- ========================================================================================= Preferably, use the `Generate Support String` button on the admin page's Diagnostics tab. That will auto-generate most of the info requested in this section. ========================================================================================= --> <!-- The version number, obtained from the logs (at startup) or the admin diagnostics page --> <!-- This is NOT the version number shown on the web vault, which is versioned separately from vaultwarden --> <!-- Remember to check if your issue exists on the latest version first! --> * vaultwarden version: 1.25.2 <!-- How the server was installed: Docker image, OS package, built from source, etc. * Install method: not relevant * Clients used: Web * Reverse proxy and version: not relevant * MySQL/MariaDB or PostgreSQL version: not relevant * Other relevant details: --> ### Steps to reproduce <!-- Tell us how to reproduce this issue. What parameters did you set (differently from the defaults) and how did you start vaultwarden? --> Try to log into the admin UI with an incorrect token. ### Expected behaviour HTTP response with [401 Unauthorized](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401) status code. <!-- Tell us what you expected to happen --> ### Actual behaviour HTTP response with 303 See Other redirect status code. <!-- Tell us what actually happened --> ### Comment Is this really intended from a behaviour perspective, see the implementation at https://github.com/dani-garcia/vaultwarden/blob/60ed5ff99d15dec0b82c85987f9a3e244b8bde91/src/api/admin.rs#L181 If I understand the comment https://github.com/dani-garcia/vaultwarden/discussions/2448#discussioncomment-2666185 correctly it might be intended by you as the authors/contributors, but this is as far as I know not the correct behaviour for bad requests due to user issues (-> 4xx status code) due to failing authentication (narrowing to 401 Unauthorized). While I understand the reasoning that a GET should follow the POST in this case, it does not make sense to me that a 303 is used. Thanks for looking into this already! Best, Vincent P.S.: If you agree that this can be changed to a 401 I would be happy to open the PR myself.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/vaultwarden#2015