mvdan / bitw

Minimalist BitWarden client
BSD 3-Clause "New" or "Revised" License
169 stars 15 forks source link

Sync failure due to secret fields #9

Closed AndreasBackx closed 5 years ago

AndreasBackx commented 5 years ago

Running the bitw sync command for the first time results in an unauthorized error, though I am fairly certain that I got my password correct. I'd love to try and enter my password again, but I don't see how I would do that.

$ EMAIL=me@domain.com bitw sync
Password: 
error: could not sync: Unauthorized: 

Then running the same command again results in a huge JSON dump (which I'm not going to share for obvious reasons) and the following error:

error: could not sync: json: cannot unmarshal object into Go struct field Cipher.Fields of type string

If you have any questions, let me know as I understand that you probably need the JSON dump for debugging. But I hope you understand that I cannot provide that, though I can answer the questions you have about it.

mvdan commented 5 years ago

You can always try to log in again via bitw login.

When you get the Cipher.Fields error, what's does your bitw/data.json file look like? That is, what kind of data is under that path? The directory is under UserConfigDir, as per https://github.com/golang/go/issues/29960.

Finally, do you have two-factor auth enabled?

If you share your contact details I can give you the password for my dummy test account. If you can reproduce the issue with that, you can share all the data then, as it has no sensitive information.

AndreasBackx commented 5 years ago

You can always try to log in again via bitw login.

Logging in with bitw login seems to work, I don't get any error or output after the password prompt. It still results in the same json unmarshal error when using sync though.

When you get the Cipher.Fields error, what's does your bitw/data.json file look like? That is, what kind of data is under that path? The directory is under UserConfigDir, as per golang/go#29960.

{
    "DeviceID": "REDACTED",
    "AccessToken": "REDACTED",
    "TokenExpiry": "2019-06-25T23:40:19.257287492Z",
    "KDF": 0,
    "KDFIterations": 100000,
    "LastSync": "0001-01-01T00:00:00Z",
    "Sync": {
        "Profile": {
            "ID": "",
            "Name": "",
            "Email": "",
            "EmailVerified": false,
            "Premium": false,
            "MasterPasswordHint": "",
            "Culture": "",
            "TwoFactorEnabled": false,
            "Key": "",
            "PrivateKey": "",
            "SecurityStamp": "",
            "Organizations": null
        },
        "Folders": null,
        "Ciphers": null,
        "Domains": {
            "EquivalentDomains": null,
            "GlobalEquivalentDomains": null
        }
    }
}

Finally, do you have two-factor auth enabled?

I do not have 2FA enabled, I should though and I will. Does bitw support 2FA?

If you share your contact details I can give you the password for my dummy test account. If you can reproduce the issue with that, you can share all the data then, as it has no sensitive information.

I'll email you using the email address on your website.

mvdan commented 5 years ago

Hmm, sync is just failing entirely then.

I do not have 2FA enabled, I should though and I will. Does bitw support 2FA?

It does. There's a test for it, even.

I'll email you using the email address on your website.

I've emailed you the passwords for the dummy test accounts.

AndreasBackx commented 5 years ago

Okay so I've tested it with the information you gave and the sync seems to run without any output/error. What would you like me to test next perhaps?

mvdan commented 5 years ago

Ah, I have an idea. None of my tests have any secret fields, so maybe I just got the decoding bit wrong. Let me give it a try.

mvdan commented 5 years ago

Yeah, that was it - I can reproduce now that I've added fancier secrets to my test account. Should be fixed soon.

AndreasBackx commented 5 years ago

Sweet, thanks for being so quick to respond. Let me know when I can give it a shot.

mvdan commented 5 years ago

I've fixed the error, though you can't use the custom fields in any way yet.

AndreasBackx commented 5 years ago

Thanks once more, sync seems to work now. 😀