[GH-ISSUE #2122] using a space at the beginning of otpauth:// generate a wrong OTP #49594

Closed
opened 2026-05-01 09:38:05 -05:00 by GiteaMirror · 19 comments
Owner

Originally created by @ghost on GitHub (Oct 10, 2022).
Original GitHub issue: https://github.com/bitwarden/android/issues/2122

Steps To Reproduce

Bitwarden Android, web interface and Firefox's extension are affected

  1. Open Bitwarden
  2. clone a working entry that has a valid OTP
  3. edit the cloned entry putting a space at the beginning of otpauth://... like this:
    " otpauth://..."
  4. save

Expected Result

two possible results:

  1. a space before otpauth:// is wrong, bitwarden should not generate any OTP but display a warning on the wrong OTP field
  2. bitwarden deals with wrong characters like spaces before otpauth:// and generate a working OTP

Actual Result

a wrong OTP is generated

Screenshots or Videos

No response

Additional Context

I found it while copying and pasting the otpauth:// line. Bitwarden interface's extension is small and it's not easy to immediately find what is wrong

Operating System

Android

Operating System Version

10

Device

No response

Build Version

2022.9.1 (5047)

Beta

  • Using a pre-release version of the application.
Originally created by @ghost on GitHub (Oct 10, 2022). Original GitHub issue: https://github.com/bitwarden/android/issues/2122 ### Steps To Reproduce Bitwarden Android, web interface and Firefox's extension are affected 1. Open Bitwarden 2. clone a working entry that has a valid OTP 3. edit the cloned entry putting a space at the beginning of otpauth://... like this: " otpauth://..." 5. save ### Expected Result two possible results: 1. a space before otpauth:// is wrong, bitwarden should not generate any OTP but display a warning on the wrong OTP field 2. bitwarden deals with wrong characters like spaces before otpauth:// and generate a working OTP ### Actual Result a wrong OTP is generated ### Screenshots or Videos _No response_ ### Additional Context I found it while copying and pasting the otpauth:// line. Bitwarden interface's extension is small and it's not easy to immediately find what is wrong ### Operating System Android ### Operating System Version 10 ### Device _No response_ ### Build Version 2022.9.1 (5047) ### Beta - [ ] Using a pre-release version of the application.
GiteaMirror added the good first issuebug labels 2026-05-01 09:38:06 -05:00
Author
Owner

@tangowithfoxtrot commented on GitHub (Dec 21, 2022):

Thanks, @luca-e075e!

I've confirmed the behavior and marked this as being reproducible internally.

<!-- gh-comment-id:1362176106 --> @tangowithfoxtrot commented on GitHub (Dec 21, 2022): Thanks, @luca-e075e! I've confirmed the behavior and marked this as being reproducible internally.
Author
Owner

@jayg2309 commented on GitHub (Sep 26, 2023):

Is someone working on this?
Can i work on this?

<!-- gh-comment-id:1736315404 --> @jayg2309 commented on GitHub (Sep 26, 2023): Is someone working on this? Can i work on this?
Author
Owner

@djsmith85 commented on GitHub (Sep 26, 2023):

@jayg2309 Thank you for your interest in contributing.

As a starting guide please have a look at our Contribution Guidelines. These will get you started with setting up your development environment and how to proceed with your contribution.

Please reference this issue when you create a pull request.

<!-- gh-comment-id:1736348118 --> @djsmith85 commented on GitHub (Sep 26, 2023): @jayg2309 Thank you for your interest in contributing. As a starting guide please have a look at our [Contribution Guidelines](https://contributing.bitwarden.com/). These will get you started with setting up your development environment and how to proceed with your contribution. Please reference this issue when you create a pull request.
Author
Owner

@jayg2309 commented on GitHub (Sep 26, 2023):

Okay thankyou

<!-- gh-comment-id:1736393689 --> @jayg2309 commented on GitHub (Sep 26, 2023): Okay thankyou
Author
Owner

@flooxo commented on GitHub (Oct 24, 2023):

Is this sill an open issue? I was not able to reproduce it, as the new OTP is generated correctly after adding a space. Otherwise I am happy to help solve the issue :)

<!-- gh-comment-id:1777609429 --> @flooxo commented on GitHub (Oct 24, 2023): Is this sill an open issue? I was not able to reproduce it, as the new OTP is generated correctly after adding a space. Otherwise I am happy to help solve the issue :)
Author
Owner

@FlorianLang06 commented on GitHub (Nov 8, 2023):

I tested it on my iPhone and in the Chrome extension. In Both cases the issue is still happening. It is important that its an OTP that begins with otpauth://. @flooxo if you want to fix it, feel free to do that or I try to do this.

<!-- gh-comment-id:1802381936 --> @FlorianLang06 commented on GitHub (Nov 8, 2023): I tested it on my iPhone and in the Chrome extension. In Both cases the issue is still happening. It is important that its an OTP that begins with otpauth://. @flooxo if you want to fix it, feel free to do that or I try to do this.
Author
Owner

@FlorianLang06 commented on GitHub (Nov 9, 2023):

I will wait some days and if you don't respond to this, I will fix this issue. I already know how to fix this, but if you want to fix it, I let you fix this.

<!-- gh-comment-id:1803481942 --> @FlorianLang06 commented on GitHub (Nov 9, 2023): I will wait some days and if you don't respond to this, I will fix this issue. I already know how to fix this, but if you want to fix it, I let you fix this.
Author
Owner

@flooxo commented on GitHub (Nov 9, 2023):

OK, thanks for the note. Feel free to fix it if you already know where in the code :)

<!-- gh-comment-id:1803535678 --> @flooxo commented on GitHub (Nov 9, 2023): OK, thanks for the note. Feel free to fix it if you already know where in the code :)
Author
Owner

@FlorianLang06 commented on GitHub (Nov 9, 2023):

Ok, but I have to get the project up and running first on my PC.

<!-- gh-comment-id:1803546450 --> @FlorianLang06 commented on GitHub (Nov 9, 2023): Ok, but I have to get the project up and running first on my PC.
Author
Owner

@flooxo commented on GitHub (Nov 9, 2023):

If you give me a hint where in the code something should be changed, I can do it too (it just saves time if i don't have to find out myself first). Whatever suits you best :)

<!-- gh-comment-id:1803550903 --> @flooxo commented on GitHub (Nov 9, 2023): If you give me a hint where in the code something should be changed, I can do it too (it just saves time if i don't have to find out myself first). Whatever suits you best :)
Author
Owner

@FlorianLang06 commented on GitHub (Nov 9, 2023):

I try if the setup on my PC is easy, if it isn't easy I give you a hint so you can do it

<!-- gh-comment-id:1803565277 --> @FlorianLang06 commented on GitHub (Nov 9, 2023): I try if the setup on my PC is easy, if it isn't easy I give you a hint so you can do it
Author
Owner

@FlorianLang06 commented on GitHub (Nov 9, 2023):

@flooxo Do you think its a good idea to remove the space at saving and at generation. At generating for existing entries and saving for new entries.

<!-- gh-comment-id:1803585255 --> @FlorianLang06 commented on GitHub (Nov 9, 2023): @flooxo Do you think its a good idea to remove the space at saving and at generation. At generating for existing entries and saving for new entries.
Author
Owner

@flooxo commented on GitHub (Nov 9, 2023):

Yeah, I guess the expected behavior when cloning an entry with an otp is to still have a valid otp path, right? So I would suggest to just trim the whitespaces

<!-- gh-comment-id:1803645120 --> @flooxo commented on GitHub (Nov 9, 2023): Yeah, I guess the expected behavior when cloning an entry with an otp is to still have a valid otp path, right? So I would suggest to just trim the whitespaces
Author
Owner

@FlorianLang06 commented on GitHub (Nov 9, 2023):

I can't get xamarin running. @flooxo you can solve this issue. In this method the key must be trimmed because the StartwWith check don't work 793c5fef6f/src/Core/Services/TotpService.cs (L21)

You can also search for the code where a entry get saved and trim the string before saving

<!-- gh-comment-id:1804331574 --> @FlorianLang06 commented on GitHub (Nov 9, 2023): I can't get xamarin running. @flooxo you can solve this issue. In this method the key must be trimmed because the StartwWith check don't work https://github.com/bitwarden/mobile/blob/793c5fef6f64b3c75b801874750d5ac26bcd5a9f/src/Core/Services/TotpService.cs#L21 You can also search for the code where a entry get saved and trim the string before saving
Author
Owner

@flooxo commented on GitHub (Nov 9, 2023):

Ok, thanks, I've already looked at that method. I'll have to take a closer look at where the key is saved, because wouldn't it be a better solution if it was already saved correctly beforehand?

<!-- gh-comment-id:1804369142 --> @flooxo commented on GitHub (Nov 9, 2023): Ok, thanks, I've already looked at that method. I'll have to take a closer look at where the key is saved, because wouldn't it be a better solution if it was already saved correctly beforehand?
Author
Owner

@FlorianLang06 commented on GitHub (Nov 9, 2023):

Yes, but I think trim it at the generation is also necessary for keys which are already stored wrong.

<!-- gh-comment-id:1804416105 --> @FlorianLang06 commented on GitHub (Nov 9, 2023): Yes, but I think trim it at the generation is also necessary for keys which are already stored wrong.
Author
Owner

@FlorianLang06 commented on GitHub (Nov 12, 2023):

@flooxo would you also try to fix this in the browser extensions? If not I can try it.

I think it's a good idea to create an new issue there and attach the link of this issue, so anyone has the context to the issue.

<!-- gh-comment-id:1807177204 --> @FlorianLang06 commented on GitHub (Nov 12, 2023): @flooxo would you also try to fix this in the browser extensions? If not I can try it. I think it's a good idea to create an new issue there and attach the link of this issue, so anyone has the context to the issue.
Author
Owner

@flooxo commented on GitHub (Nov 12, 2023):

Sure, i'll give it a try. Thanks :)

<!-- gh-comment-id:1807236825 --> @flooxo commented on GitHub (Nov 12, 2023): Sure, i'll give it a try. Thanks :)
Author
Owner

@vvolkgang commented on GitHub (Jun 20, 2024):

Issue migrated to https://github.com/bitwarden/mobile/issues/2122

<!-- gh-comment-id:2181393636 --> @vvolkgang commented on GitHub (Jun 20, 2024): Issue migrated to https://github.com/bitwarden/mobile/issues/2122
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#49594