Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Use rpmkeys alone to verify the signature #1753

Merged

Conversation

DemiMarie
Copy link
Contributor

This avoids having to actually import the package to check its signature, which reduces attack surface. Marking as RFC because this is critical code and I have not tested this much.

@lgtm-com
Copy link

lgtm-com bot commented Apr 9, 2021

This pull request introduces 3 alerts when merging ac20a40 into b3d2700 - view on LGTM.com

new alerts:

  • 3 for Unused import

@pep8speaks
Copy link

pep8speaks commented Apr 11, 2021

Hello @DemiMarie! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 28:1: E302 expected 2 blank lines, found 1
Line 36:1: E302 expected 2 blank lines, found 1
Line 63:1: E302 expected 2 blank lines, found 1
Line 103:40: E227 missing whitespace around bitwise or shift operator
Line 103:52: E227 missing whitespace around bitwise or shift operator

Comment last updated at 2021-06-02 17:44:10 UTC

@lgtm-com
Copy link

lgtm-com bot commented Apr 11, 2021

This pull request introduces 3 alerts when merging 41ac6c0 into b3d2700 - view on LGTM.com

new alerts:

  • 3 for Unused import

@DemiMarie
Copy link
Contributor Author

I filed rpm-software-management/ci-dnf-stack#983 for the CI failure.

dnf/rpm/miscutils.py Outdated Show resolved Hide resolved
dnf/rpm/miscutils.py Outdated Show resolved Hide resolved
dnf/rpm/miscutils.py Outdated Show resolved Hide resolved
dnf/rpm/miscutils.py Outdated Show resolved Hide resolved
dnf/rpm/miscutils.py Show resolved Hide resolved
dnf/rpm/miscutils.py Show resolved Hide resolved
dnf/rpm/miscutils.py Outdated Show resolved Hide resolved
dnf/rpm/miscutils.py Outdated Show resolved Hide resolved
dnf/rpm/miscutils.py Show resolved Hide resolved
dnf/rpm/miscutils.py Outdated Show resolved Hide resolved
@DemiMarie DemiMarie force-pushed the improved-sig-check branch 4 times, most recently from 895a8a3 to 8d2b69f Compare May 18, 2021 19:58
@DemiMarie DemiMarie requested a review from kontura May 18, 2021 22:03
Copy link
Contributor

@kontura kontura left a comment

Choose a reason for hiding this comment

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

Except for the misbehaving log this looks good to me. 👍

dnf/rpm/miscutils.py Outdated Show resolved Hide resolved
@kontura
Copy link
Contributor

kontura commented May 31, 2021

@DemiMarie what is the status here?
I saw you reverted back to '--define=_pkgverify_level all' is that because of rpm-software-management/rpm#1672?

@DemiMarie
Copy link
Contributor Author

@DemiMarie what is the status here?

This PR should be ready for production use, but I would like a review first.

I saw you reverted back to '--define=_pkgverify_level all' is that because of rpm-software-management/rpm#1672?

No, it is for consistency with the previous version. Changing %_pkgverify_level should be a separate change.

@kontura
Copy link
Contributor

kontura commented Jun 1, 2021

This PR should be ready for production use, but I would like a review first.

I think the only thing we need is to fix the logger I mentioned in #1753 (comment).

@DemiMarie
Copy link
Contributor Author

This PR should be ready for production use, but I would like a review first.

I think the only thing we need is to fix the logger I mentioned in #1753 (comment).

See my comment w.r.t. threading.

dnf/rpm/miscutils.py Outdated Show resolved Hide resolved
This avoids having to actually parse the package to check its signature,
which reduces attack surface.  If the output of rpmkeys cannot be
parsed, we assume the package is corrupt (the most likely cause).
Copy link
Contributor

@kontura kontura left a comment

Choose a reason for hiding this comment

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

Thank you for all the help!

@kontura kontura merged commit a21880f into rpm-software-management:master Jun 3, 2021
@DemiMarie
Copy link
Contributor Author

Thank you for all the help!

You’re welcome!

# "--define=_pkgverify_flags 0x0" ensures that all signatures and digests
# are checked.
args = ('rpmkeys', '--checksig', '--root', installroot, '--verbose',
'--define=_pkgverify_level all', '--define=_pkgverify_flags 0x0',
Copy link
Member

@pmatilai pmatilai Jun 3, 2021

Choose a reason for hiding this comment

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

_pkgverify_level all is wrong for this purpose. This is about checking signatures, and pulling digests into the picture WILL cause breakage of certain use-cases in FIPS mode.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. I made #1775 for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That belongs as a separate change, which is why I reverted it.

@pmatilai
Copy link
Member

pmatilai commented Jun 3, 2021

As a side-effect of this, there will be an extra rpmdb open + read for each package to be checked. It may not be an actual issue, but it's quite a bit of extra churn added and people should at least be aware of it.

Using an external process will also affect some distro upgrade scenarios, but as long as its only ever used before starting a transaction, it's probably not much of an issue.

kontura added a commit to kontura/dnf that referenced this pull request Jun 3, 2021
kontura added a commit to kontura/dnf that referenced this pull request Jun 3, 2021
@DemiMarie DemiMarie deleted the improved-sig-check branch June 3, 2021 17:24
kontura added a commit to kontura/dnf that referenced this pull request Aug 4, 2021
We don't want to be veryfing digests as well when checking signatures.
It would break legacy package installation in FIPS mode due to MD5
digest being unverifiable (see https://access.redhat.com/solutions/5221661)

Follow up for rpm-software-management#1753
j-mracek pushed a commit that referenced this pull request Aug 4, 2021
We don't want to be veryfing digests as well when checking signatures.
It would break legacy package installation in FIPS mode due to MD5
digest being unverifiable (see https://access.redhat.com/solutions/5221661)

Follow up for #1753
pkratoch pushed a commit that referenced this pull request Nov 9, 2021
We don't want to be veryfing digests as well when checking signatures.
It would break legacy package installation in FIPS mode due to MD5
digest being unverifiable (see https://access.redhat.com/solutions/5221661)

Follow up for #1753
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.

None yet

4 participants