Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 901385 - git sync: Add sync-git-verify-commit-signature "if-signed" mode and default to it
Summary: git sync: Add sync-git-verify-commit-signature "if-signed" mode and default t...
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Enhancement/Feature Requests (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-15 20:54 UTC by Florian Schmaus
Modified: 2023-12-14 08:47 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Schmaus gentoo-dev 2023-03-15 20:54:15 UTC
The sync-git-verify-commit-signature option currently defaults to false. This means that a user can easily fall into the trap of configuring a git-based sync of ::gentoo that does not verify the commit. Simply by not explicitly specifying "sync-git-verify-commit-signature = true".

I think it would be sensible to add a third configuration value for the sync-git-verify-commit-signature option named 'if-signed', and have the option default to 'if-signed'. This way, a user configuring a git-based sync for a repository with signed commits will become immediately aware if the commit could not be verified.

The user has then the option to either configure appropriate trusted keys for the repository or to disable commit verification. But the user will not, probably unintentionally, sync from a remote without commit verification. Which is the threat of the current behavior.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-03-15 20:59:35 UTC
A malicious remote could just strip the signatures though? It's the same issue with relying on opportunistic HTTPS.

>This way, a user configuring a git-based sync for a repository with signed commits will become immediately aware if the commit could not be verified.

I don't see how this follows, given the above. What am I missing?
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-03-15 21:00:40 UTC
I guess you mean it'd try and fail to verify for a non-malicious repo and then they'd be forced to set keys and switch to yes or disable explicitly.
Comment 3 Florian Schmaus gentoo-dev 2023-03-15 21:03:48 UTC
I just realized that a 'if-signed' option requires a "pinning behavior". That is, if 'if-signed' is enabled, then, on the initial clone the head commit should be checked for a commit signature. And if there is one, this should be remembered and signed commits should be required for all subsequent clones/updates.

But this still leaves a short window for an attacker open. Maybe this bug is really about defaulting sync-git-verify-commit-signature to true, or to hardcode a list of git repo URLs where we expect that the HEADs of the sync branch are always pointing to signed commits (an option I personally do not really like).

In any case, defaulting sync-git-verify-commit-signature to 'false' is insecure and probably the worst of the available options.
Comment 4 Florian Schmaus gentoo-dev 2023-03-15 21:12:34 UTC
(In reply to Sam James from comment #2)
> I guess you mean it'd try and fail to verify for a non-malicious repo and
> then they'd be forced to set keys and switch to yes or disable explicitly.

Correct. And what you pointed out is also right. Something like 'is-signed' only makes sense if you only inspect the commit after the initial clone, and then require that all subsequent commits will have signed commits if the initial clone's commit had one.

Another option, that occurred to me, would potentially be to set the value of sync-git-verify-commit-signature depending on the name of the repository: if it is 'gentoo' then default to 'true'.
Comment 5 Enne Eziarc 2023-03-15 23:23:30 UTC
How is this supposed to interact with overlays? If it's on by default for those then a bunch of them will immediately break due to using signed commits and Gentoo not providing a good way to distribute those keys.
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-04-11 23:48:39 UTC
(In reply to Enne Eziarc from comment #5)
> How is this supposed to interact with overlays? If it's on by default for
> those then a bunch of them will immediately break due to using signed
> commits and Gentoo not providing a good way to distribute those keys.

That question is covered above, the opportunistic aspect. There's no plan for distributing those keys but there's also obviously no plan to then break overlays by requiring it.

(I think we discussed it more on IRC at the time too, you need some HSTS style pinning really and maybe an initial list.)