Skip to content

Conversation

emlun
Copy link
Owner

@emlun emlun commented Aug 12, 2024

This is a meta-PR into:

The changes are unfortunately tangled with those of meta-PR #5, so for review one may want to ignore the first three commits.

@imsodin I believe this should address the second half of syncthing#9175 (comment).

@emlun emlun changed the title Webauthn state config Move WebAuthn state back to config, but outside GUIConfiguration Aug 12, 2024
@imsodin
Copy link

imsodin commented Aug 25, 2024

Moving it to config makes sense. I'd prefer if you moved it into the gui config, since it's only relevant to the gui, and then ignored it for restarts. There's already prior art for doing that: https://github.com/syncthing/syncthing/blob/main/lib/api/api.go#L484

@acolomb
Copy link

acolomb commented Aug 27, 2024

I second the request to move these credential settings to the GUI configuration section. However, with one restriction:

When using the WebAuthn login, the signature counter and last used timestamp fields are updated each time. Both are done for added security. But it's a new scenario regarding our config handling, because so far starting up Syncthing without doing any configuration changes won't try rewriting the config file. Thus in theory, config.xml could be write-protected, but no longer with this change.

So I suggest to keep these two dynamically changing fields out of the config. We can add them to the database for the added security, but that could even be a second step after getting WebAuthn working at all. When the database is reset, this info would be lost, but that's uncritical. The signature counter just needs to be smaller than what the authenticator reports (which zero always is), and the last used timestamp is just for the user to investigate.

This would also mitigate some of the concurrency / locking concerns, at least for the registration side, where serializing config changes is already taken care of.

What do you think @emlun and @imsodin?

@imsodin
Copy link

imsodin commented Sep 13, 2024

IMO changing config is a non-concern resp. non-writable config is not workable anyway. Pretty sure syncthing will crash and burn eventually. E.g. when the first device/folder share request comes in.

In principle I agree that such counters/timestamps are a stretch to call config. Practically I don't feel like requiring changes/complexity just to avoid that (my opinon only of course).

I am out of the loop on the concurrency/locking concerns, no comment there.

@acolomb
Copy link

acolomb commented Sep 13, 2024

Why should it crash with a read-only config? Sharing requests are stored in the DB. What else do you see that requires config writing at random times? I think it's a worthy goal to not depend on writable config files.

@imsodin
Copy link

imsodin commented Sep 13, 2024

Device config pending and ignored folders. Crash and burn was meant figuratively, and yeah acked, would be better to avoid that in my comms. And checking what happens for real, indeed it won't crash and burn, it will just not persist the change and warn the user about that.

My main issue is feature creap. Irrespective of a goal being worthy, I don't think it's fair to put higher standards to a new contribution than what's existing. Also worth repeating that I do agree with the desire to not put those values into config, I just want to weigh that against additional work and complexity it may induce. If emlun agrees and feels the work isn't an issue, by all means lets move it out of the config, but I don't feel it's worth blocking the PR over.

@acolomb
Copy link

acolomb commented Sep 14, 2024

Well this is already a meta-PR into the actual syncthing PR and I find that approach works out very well. We can have thorough discussions and help out with finishing the feature, without inflating the main PR needlessly. And correct me if I got it wrong @emlun, but I think you welcome this input to make sure the feature is integrated fully-baked, with all concerns about the code addressed. In this case I don't think it's feature creep, as the info needs to be stored somewhere and we already have working proposals for both DB and config storage. Separating and moving around some settings shouldn't be much more effort then.

I've experienced what it takes to change such misplaced storage decisions, that was actually my first big PR to Syncthing - moving the pending folders / devices from config to the DB (syncthing#6443). That's why I'm certain this part is not something that prevents having a read-only config. People who care about write-protecting a config file will be aware that saving settings from the GUI will fail. But pending device requests or updating counters for the login process happens in the background and should not fail silently.

@emlun
Copy link
Owner Author

emlun commented Sep 15, 2024

Of course it would be nice if one could always nail it on the first try, but I've done software dev long enough to know that most features take more than a few iterations before you decide on a solution you're happy with. 🙂 And yes, I tend to prefer getting things complete enough to not require additional changes for them to be functional or to fix things that (knowingly) broke in the initial change set.

I do agree that most of this isn't really "config", since you can't type the credential ID and public key in manually - even with the help of format converter tools - but need to perform the setup ceremony together with the authenticator. But maybe config is still the best home for it, at least of the currently built in storage options. At least the static parts, that is. I like the idea of moving just the dynamic parts (counter and last used) into DB - as you say, these two can always be reconstructed on next login in case the user resets the DB, so that's no big deal either. I tried this out and I think I like it, so I'll update the PR with this. I've rebased on top of the current state of syncthing#9175 to untangle this from #5.

@emlun emlun force-pushed the webauthn-state-config branch from 6423181 to f06f5e6 Compare September 15, 2024 17:11
@emlun emlun changed the title Move WebAuthn state back to config, but outside GUIConfiguration Move WebAuthn state back into GUIConfiguration, except SignCount and LastUseTime Sep 15, 2024
@emlun
Copy link
Owner Author

emlun commented Sep 21, 2024

@imsodin @acolomb Do you want to re-review these changes here before I merge them into syncthing#9175?

Copy link

@acolomb acolomb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just skimmed over the changes and didn't spot anything sticking out. Will do more review / testing on the main PR.

@imsodin
Copy link

imsodin commented Sep 28, 2024

Also just had a quick look over it - no further review outstanding from my side to merge this.

@emlun emlun merged commit fe68527 into webauthn Sep 28, 2024
@emlun emlun deleted the webauthn-state-config branch September 28, 2024 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants