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

rpm_key key_id verification erroneous #23558

Closed
schwatvogel opened this issue Apr 13, 2017 · 2 comments
Closed

rpm_key key_id verification erroneous #23558

schwatvogel opened this issue Apr 13, 2017 · 2 comments
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@schwatvogel
Copy link
Contributor

schwatvogel commented Apr 13, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible/modules/packaging/os/rpm_key.py

ANSIBLE VERSION
ansible 2.2.1.0
CONFIGURATION

not relevant

OS / ENVIRONMENT

N/A
Redhat/Centos rpm-based

SUMMARY

Function is_key_imported does not work reliably because
Function getkeyid only extracts the last part of the first signature packet,ignoring the significant other ids
therefore the key will be imported on every ansible run

STEPS TO REPRODUCE

Install the Mono gpg key (from the Ubuntu keyserver, as per official docu):

http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
Short Summary:

getkeyid() essentially runs
gpg --no-tty --batch --with-colons --fixed-list-mode --list-packets /tmp/key.1 |grep signature
And returns the last 8 characters of the first key id it finds:
90E1FAD0C
instead of all keyids in this package:

C90F9CB90E1FAD0C
01150A655BBD8102
A6A19B38D3D831EF
A6A19B38D3D831EF

Then is_key_imported() runs
rpm -qa gpg-pubkey and matches the keyid against the first key part of the filename:
gpg-pubkey-d3d831ef-53dfa827

This does'nt work with the Mono key because the partial keyid in the filename is from the second keyid in the key

Possible Solutions:

Perhaps verifying the Fingerprint of the keys, or
verify the full key ids:
Fetching the full 16 Character key-ids (all of them not just the first)
and verify them against all installed key ids (not just rpm names)
by listing all installed gpgkeys and extracting the keyids in the same way, as the are extracted from the reference keys:
rpm -qa gpg-pubkey --qf "%{description}"| gpg --no-tty --batch --with-colons --fixed-list-mode --list-packets -

@ansibot
Copy link
Contributor

ansibot commented Apr 13, 2017

@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. labels Apr 13, 2017
@ansibot
Copy link
Contributor

ansibot commented Apr 13, 2017

@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. labels Apr 13, 2017
@nitzmahone nitzmahone removed the needs_triage Needs a first human triage before being processed. label Apr 13, 2017
schwatvogel pushed a commit to schwatvogel/ansible that referenced this issue Apr 18, 2017
changed to "full key" comparison instead of  "short keyid to rpm-filename"
changed rpm keyid extraction method
@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jun 29, 2017
schwatvogel pushed a commit to schwatvogel/ansible that referenced this issue Aug 2, 2017
changed to "full key" comparison instead of  "short keyid to rpm-filename"
changed rpm keyid extraction method
@abadger abadger closed this as completed in b8d371c Aug 8, 2017
abadger pushed a commit that referenced this issue Aug 9, 2017
* Changed rpm-keyid extraction and verification method
* minor style fixes
* fixed rpm key deletion,added integration test for mono key,fixed wording in integration tests

(cherry picked from commit b8d371c)
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

3 participants