Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 619988 - Portage-utils: Compare digests of installed files with IMA
Summary: Portage-utils: Compare digests of installed files with IMA
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Enhancement/Feature Requests (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Fabian Groffen
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-28 09:44 UTC by Sam
Modified: 2018-05-18 12:27 UTC (History)
0 users

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


Attachments
add qtegrity to portage-utils (qtegrity.patch,7.13 KB, patch)
2017-05-28 09:45 UTC, Sam
Details | Diff
Fixed description of the flag (qtegrity-fix-flag-description.patch,729 bytes, patch)
2017-05-29 21:12 UTC, Sam
Details | Diff
Determine IMA digest types (qtegrity-determine-hashfunc.patch,6.15 KB, patch)
2017-06-05 11:16 UTC, Sam
Details | Diff
Allowing adding custom digest (qtegrity-allow-adding-custom-digest.patch,5.68 KB, patch)
2017-06-05 20:57 UTC, Sam
Details | Diff
allow adding custom digest (fix recorded filename) (qtegrity-allow-adding-custom-digest-2.patch,5.67 KB, patch)
2017-06-05 21:07 UTC, Sam
Details | Diff
Man page for qtegrity (qtegrity.1,1.58 KB, text/plain)
2018-04-29 20:53 UTC, Sam
Details
New man page, including new flag to only show succesfully matched digests (qtegrity.1,1.68 KB, text/plain)
2018-05-06 20:53 UTC, Sam
Details
Complete c file, replacing previous patches (qtegrity.c,11.03 KB, text/x-csrc)
2018-05-06 20:57 UTC, Sam
Details
New version, uses pipe-fork-exec and replaces custom digests instead of blindly appending (qtegrity.c,12.15 KB, text/x-csrc)
2018-05-12 11:31 UTC, Sam
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sam 2017-05-28 09:44:21 UTC
Gentoo creates a mountain of metadata-gold while installing packages. From security especially the digests of installed files are interesting. An online integrity check against these can be performed using IMA, the linux kernel facility that records digests of all executed files.

This patch assumes IMA is enabled and assumes the existence of a file /var/db/QTEGRITY containing lines of:
sha256:<digest> file:/some/file

Reproducible: Always
Comment 1 Sam 2017-05-28 09:45:46 UTC
Created attachment 474532 [details, diff]
add qtegrity to portage-utils
Comment 2 Sam 2017-05-29 21:12:13 UTC
Created attachment 474678 [details, diff]
Fixed description of the flag
Comment 3 Sam 2017-06-05 11:16:49 UTC
Created attachment 475232 [details, diff]
Determine IMA digest types

No longer assume IMA only publishes sha256 digests but determine the used hash func based on the string prefix.
Comment 4 Sam 2017-06-05 20:57:38 UTC
Created attachment 475294 [details, diff]
Allowing adding custom digest

With this patch the user can provide a filename, the the utility checks whether the file is accessible and is an executable, then it records its digest to a customization file.
Comment 5 Sam 2017-06-05 21:07:42 UTC
Created attachment 475298 [details, diff]
allow adding custom digest (fix recorded filename)
Comment 6 Fabian Groffen gentoo-dev 2018-03-26 19:50:11 UTC
I'm willing to add this to portage-utils, can you please upload the last version of the new file and add a manpage for your applet?  I can't test this myself, so I'll have to rely on you here.
Comment 7 Sam 2018-04-15 10:19:41 UTC
Will do
Comment 8 Sam 2018-04-29 20:53:08 UTC
Created attachment 528952 [details]
Man page for qtegrity

Here's a man page for this applet. Still working on the c file, hoping to find some time for it in the coming days.
Comment 9 Sam 2018-05-06 20:53:58 UTC
Created attachment 530276 [details]
New man page, including new flag to only show succesfully matched digests
Comment 10 Sam 2018-05-06 20:57:20 UTC
Created attachment 530278 [details]
Complete c file, replacing previous patches

Here's the c file. It's changed a bit since the previous patches. I ran it through valgrind and fixed some memory handling. Also I added a flag to optionally show successfully matched digests.
Comment 11 Sam 2018-05-12 11:31:09 UTC
Created attachment 531030 [details]
New version, uses pipe-fork-exec and replaces custom digests instead of blindly appending
Comment 12 Larry the Git Cow gentoo-dev 2018-05-18 10:15:26 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=04b4c6834fd83bf0329198c56894bd7dad6f7a6a

commit 04b4c6834fd83bf0329198c56894bd7dad6f7a6a
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2018-05-18 10:12:40 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2018-05-18 10:12:40 +0000

    qtegrity: new applet by Sam Besselink for use with IMA, bug #619988
    
    Bug: https://bugs.gentoo.org/619988

 applets.h                                      |   7 +-
 man/include/qtegrity-70-relevant-files.include |   9 +
 man/include/qtegrity-authors.include           |   1 +
 man/include/qtegrity.desc                      |   8 +
 man/qtegrity.1                                 |  81 ++++
 qtegrity.c                                     | 509 +++++++++++++++++++++++++
 6 files changed, 614 insertions(+), 1 deletion(-)
Comment 13 Larry the Git Cow gentoo-dev 2018-05-18 12:27:39 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=47d5c9788b9550078e17aad238fa03cabe20fd46

commit 47d5c9788b9550078e17aad238fa03cabe20fd46
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2018-05-18 12:27:07 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2018-05-18 12:27:23 +0000

    app-portage/portage-utils: version bump to v0.71
    
    Closes: https://bugs.gentoo.org/619988
    Closes: https://bugs.gentoo.org/653202
    Closes: https://bugs.gentoo.org/652312
    Closes: https://bugs.gentoo.org/652720
    Closes: https://bugs.gentoo.org/653032
    Package-Manager: Portage-2.3.24, Repoman-2.3.6

 app-portage/portage-utils/Manifest                                | 2 +-
 .../{portage-utils-0.65.ebuild => portage-utils-0.71.ebuild}      | 8 --------
 2 files changed, 1 insertion(+), 9 deletions(-)