dani-garcia / vaultwarden

Unofficial Bitwarden compatible server written in Rust, formerly known as bitwarden_rs
GNU Affero General Public License v3.0
39.02k stars 1.89k forks source link

SMTP E-Mail sending error still reports as success in UI #791

Closed Zauberfisch closed 3 years ago

Zauberfisch commented 4 years ago

Subject of the issue

When bitwarden_rs tries to send emails via SMTP, not all errors will actually be recognised as errors.

Your environment

Steps to reproduce

Started through systemd unit file from AUR package

Cause one of the following errors when sending via SMTP:

Expected behaviour

UI should tell the user that sending an email failed

Actual behaviour

Green notification pops up saying it was sent

Relevant logs

Jan 01 00:22:39 bitwarden.my-domain.com bitwarden_rs[633]: [2020-01-01 00:22:39][_][INFO] Matched: POST /api/accounts/verify-email (post_verify_email)
Jan 01 00:22:39 bitwarden.my-domain.com bitwarden_rs[633]: [2020-01-01 00:22:39][lettre::smtp::client][DEBUG] connecting to 10.20.30.40:465
Jan 01 00:22:54 bitwarden.my-domain.com bitwarden_rs[633]: [2020-01-01 00:22:54][bitwarden_rs::api::core::accounts][ERROR] Error sending delete account email: Error sending email. connection timed out
Jan 01 00:22:54 bitwarden.my-domain.com bitwarden_rs[633]: [2020-01-01 00:22:54][_][INFO] Outcome: Success
PrivatePuffin commented 4 years ago

I can confirm and limit the error scope somewhat: When doing an invite from the organisation screen this does give the right error. When doing a email verification from the user homescreen, it gives a screen "everything okey", even when failing.

sekdiy commented 4 years ago

I can confirm that this is still relevant and also affects the Test SMTP (Send test email) functionality in the admin panel.

I just caused an authentication error, but all tests were reported successful.

dani-garcia commented 4 years ago

The server always returns errors when it gets them, but some client endpoints don't handle them and they always show success, there's not much we can do about those as they probably aren't related to bitwarden_rs.

That said, if this happens in the admin panel we should be handling them correctly, @sekdiy can you check the network requests tab in your browser to see what response you get from the /admin/test/smtp/ endpoint?

Zauberfisch commented 4 years ago

@dani-garcia I think this is in fact a bitwarden_rs issue.

In the log file I posted, the last line says:

Jan 01 00:22:54 bitwarden.my-domain.com bitwarden_rs[633]: [2020-01-01 00:22:54][_][INFO] Outcome: Success

The Outcome: Success leads me to believe this is wrongly handled on the server

When I click on "Verify Email -> Send Email" on a new Account, the HTTP Response is an empty body with the following headers:

HTTP/1.1 200 OK
Server: Rocket
Feature-Policy: accelerometer 'none'; ambient-light-sensor 'none'; autoplay 'none'; camera 'none'; encrypted-media 'none'; fullscreen 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture 'none'; sync-xhr 'self' https://haveibeenpwned.com https://twofactorauth.org; usb 'none'; vr 'none'
Referrer-Policy: same-origin
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: frame-ancestors 'self' chrome-extension://nngceckbapebfimnlniiiahkandclblb moz-extension://*;
Cache-Control: no-cache, no-store, max-age=0
Access-Control-Allow-Origin: https://bitwarden.my-domain.com
Content-Length: 0
Date: Thu, 14 May 2020 12:21:07 GMT
PrivatePuffin commented 4 years ago

I agree with @Zauberfisch I also saw the success originating from bitwarden_rs in the logs when I looked into this.

BlackDex commented 4 years ago

There have been a lot changes done to the email library since the last comment here. If this still is an issue please give some more details.

l0rem commented 4 years ago

1.16.3 as of today - the issue is still there.

BlackDex commented 4 years ago

@l0rem Could you give us an example maybe, which steps to reproduce this, and what message do you get in the logs?

BlackDex commented 3 years ago

@Zauberfisch, @l0rem and @sekdiy Have you tried v1.17.0 already? That version includes a lot of changes to handling emails and has some better error reporting. And does it still produce any error.

Also, i just have create a new PR #1229 which could help in trying to debug this issue. We have to wait for this PR to be merged for you to test (unless you build it your self).

BlackDex commented 3 years ago

As of today there is a new testing version available on docker hub which has among an updated mail library, also an SMTP_DEBUG option available. Maybe this could help i troubleshooting this issue.

BlackDex commented 3 years ago

Going to close this one because of inactivity and there have been some more changes done including the SMTP_DEBUG option. If this issue still is unsolvable using that feature please feel free to re-open this ticket.