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

IMA policy enhancement proposal #71

Merged
merged 1 commit into from
Sep 27, 2022
Merged

Conversation

THS-on
Copy link
Member

@THS-on THS-on commented Apr 1, 2022

Accompanies #70

@THS-on THS-on requested review from mpeters and mbestavros April 1, 2022 18:37
Copy link
Member

@lukehinds lukehinds left a comment

Choose a reason for hiding this comment

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

Thanks for getting this started, I think we need to do a fair amount of planning around this as if we need to extend at some point in the future we can do so without being fixed to a certain manifest layout. I am imagining having manifest agility so allowlists can be consumed from different providers. We did something like this in rekor with what we call custom types, this way we can support multiple crypt algs and different manifest layouts and even formats.

I will sketch some ideas out in a doc and share them.

We also need to think how this marries with the signature verification and the multi allowlist work.

70_ima_policy.md Show resolved Hide resolved
70_ima_policy.md Show resolved Hide resolved
70_ima_policy.md Outdated Show resolved Hide resolved
@THS-on
Copy link
Member Author

THS-on commented Apr 1, 2022

@lukehinds this proposal only is the unification of the settings into a single policy and does not contain anything more, but I agree if we want to consume other formats directly we should plan ahead to make your life easier in the future.

@THS-on
Copy link
Member Author

THS-on commented May 24, 2022

@mpeters @lukehinds @maugustosilva I think this proposal is ready.

For the actual signature format should be either part of #65 or a new enhancement.

@aplanas
Copy link

aplanas commented May 27, 2022

Incidentally I am trying to push this in createrepo_c: rpm-software-management/createrepo_c#316

One problem that I found is that when we try to generate the list of IMA hashes we need to: (1) access the monitored machine to calculate the hashes or (2) download all the RPMs / Debs from the repositories and fetch from there (maybe in the header) the hashed data.

The second option has the advantage that we know for sure that the hash is correct (it is signed and we can validate it), but is very slow and hard synchronize when there is an update.

For that, the patch in createrepo_c will add a new metadata file that contains all the hashes of the files that can be installed. This method is again secure (signed), and is also friendly to updates (http etag).

@lukehinds
Copy link
Member

sorry for radio silence, am reviewing now

Copy link
Member

@lukehinds lukehinds left a comment

Choose a reason for hiding this comment

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

This looks good to me, with a caveat we can evolve the schema over time (things liked attached sigs which we discussed in this issue).

70_ima_policy.md Outdated Show resolved Hide resolved
@THS-on
Copy link
Member Author

THS-on commented Jun 16, 2022

@lukehinds thanks for the review.

This looks good to me, with a caveat we can evolve the schema over time (things liked attached sigs which we discussed in this issue).

Yes. As already mentioned this is just pulling all the IMA options into one single JSON object. The signature in this object is for IMA (ima-sig) validation and not for validating the JSON object. The proposal for adding signature validation for the IMA policy will be finalized once keylime/keylime#994 is merged and this proposal is implemented.


For users of the old flat file format a upgrade path using a commandline tool
will be provided.

Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to have backwards compatability, at least for a couple of versions? It's fine if it's deprecated and issues a warning.

Copy link
Member Author

Choose a reason for hiding this comment

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

Kinda, but not really. Ideally we want to make the tenant simpler to use and not more complicated. Removing and providing a tool is easier than trying to build backwards compatability into the tenant long term.

When I asked there was still the need for the flat file format (I think it came from @maugustosilva) and with that approach we can support as long as needed, but no longer as a main part of the tenant.

Copy link
Member

Choose a reason for hiding this comment

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

My main concern is that keylime_tenant for most people is THE interface for keylime and making backwards incompatible changes without a deprecation cycle is going to cause more and more problems as adoption increases. Especially after it starts landing in major OS distros soon. Maybe that's not an issue with this change, but I'm concerned about the precedent it sets.

Maybe a compromise is to have the tenant accept all of the old arguments and do one of the following:

  1. Issue a deprecation warning and use the new tool in the background to do the conversion.
  2. Issue an error message and helpfully point the user at the new conversion tool

In my mind the 1st is a superior user experience, but I can probably be convinced that the 2nd is better to keep the code cleaner.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should think about how many people are actually using the IMA feature today and make our decision based on that. I think that for new users the current tenant commandline interface is not really usable. It has way too many options, which are not really used. I'm fine with implementing the second idea.

When Keylime ships in e.g. RHEL it will be probably frozen on one mayor version right? So then it will be always an upgrade issue between the last shipped one and the current master.

70_ima_policy.md Show resolved Hide resolved
70_ima_policy.md Show resolved Hide resolved
70_ima_policy.md Show resolved Hide resolved
70_ima_policy.md Show resolved Hide resolved
70_ima_policy.md Show resolved Hide resolved
70_ima_policy.md Outdated Show resolved Hide resolved
70_ima_policy.md Show resolved Hide resolved
@lukehinds
Copy link
Member

Just some json schema validation notes:

"verification-keys": {
            "type": "array",
            "title": "Public keys to verify IMA attached signatures",
            "items": "string"
        },

Expected property to contain an array or schema (Object or Boolean), but found a String.

"verification-keys": {
            "type": "array",
            "title": "Public keys to verify IMA attached signatures",
            "items": { 
              "key1": ["abcd"],
              "key2": ["abcd"]
            }
        },

@lukehinds
Copy link
Member

lukehinds commented Jun 16, 2022

I would like to offer up the following for consideration. Understand this may need another enhancement, but would like any code to have in mind an extendable interface. This would allow signing of the body / envelope for attached sigs:

{
    "signatures": [
        {
         "keyid": "{hex-encoded-digest-of-pubkey-or-x509-pem-certificate}",
         "sig": "{hex-encoded-signature}"
        }
    ],
    "signed": {
        "meta": {
        "version": 872
        },
        "release": 774.75,
        "hashes": {
        ",'Sr": []
        },
        "excludes": [],
        "keyrings": {
        "}": "ABCDEFGHIJK"
        },
        "ima": {
        "ignored_keyrings": [],
        "log_hash_alg": "ABCDEFGHIJKLMNOPQRS"
        },
        "ima-buf": {
        "": "ABCDEFGH"
        },
        "verification-keys": []
    }
}

hex, could also be b64

@THS-on
Copy link
Member Author

THS-on commented Jun 17, 2022

@lukehinds the schema had an error. This should now be fixed.

For the signatures: I would move this discussion to a new proposal, because this is outside the scope of this one.

@lukehinds
Copy link
Member

@lukehinds the schema had an error. This should now be fixed.

For the signatures: I would move this discussion to a new proposal, because this is outside the scope of this one.

understood, but I want to make sure any work we do here (as a result of this enhancement) is not going to make it problematic (api breaking) to implement an attached signature envelope as a follow up.

I will implement the enhancement asap, and we can then look to introduce both at the same time, rather than hit a non-backwards compat changen twice over.

@THS-on THS-on force-pushed the ima-policy branch 2 times, most recently from f5f9c36 to 8024f4c Compare June 17, 2022 13:12
@THS-on
Copy link
Member Author

THS-on commented Jun 17, 2022

@mbestavros anything to add from your side? If not I would merge it.

@mbestavros
Copy link
Contributor

This looks great! Will definitely be a significant usability improvement, and I agree that it will be best to introduce all these improvements as one large breaking change to simplify how things are handled on tenant and verifier.

A few notes I had once I'd read through it:

  • This new format presents an opportunity to strip out a bunch of the allowlist processing steps on the tenant and verifier - ideally this becomes something we can store unmodified on the verifier (would make signature validation and the like possible). Does the current proposal have a 1:1 mapping in terms of fields used in the latest versions of Keylime allowlists? (i.e. will we need to do any post-processing? I suspect no, but just to confirm.) I notice a version field, which is good.
  • The IMA policy migration tool will be necessary, and a lot of the ideas are good. Legacy signature validation caught my eye - one potential expansion on that idea could be a --sign option or similar, where the migration tool would also handle keygen and signing of the converted IMA policy and spit out associated signing materials for use with Keylime.
  • This proposal assumes IMA policies will still be stored alongside individual agent data, which will likely not be the case for much longer - when the Allowlists API is complete, IMA policies will live in their own separate table. It's a technical detail, but one worth keeping in mind.

Most importantly, though, I agree with @lukehinds that we need to think carefully about how we want to approach signing before implementing the new policy format. We have an opportunity to future-proof that mechanism, and we should if we're making a breaking API change anyway. I don't see why that concern should block this enhancement from being merged, but I also think #79 should be merged before attempting implementation.

@THS-on
Copy link
Member Author

THS-on commented Jun 21, 2022

Does the current proposal have a 1:1 mapping in terms of fields used in the latest versions of Keylime allowlists?

Yes, there is no conversion required.

The IMA policy migration tool will be necessary, and a lot of the ideas are good. Legacy signature validation caught my eye - one potential expansion on that idea could be a --sign option or similar, where the migration tool would also handle keygen and signing of the converted IMA policy and spit out associated signing materials for use with Keylime.

Maybe, but signing using something like openssl is pretty straightforward. We should add documentation on how to do that, but I would like to keep the conversion tool as simple as possible because we are going to remove it at some point.

This proposal assumes IMA policies will still be stored alongside individual agent data, which will likely not be the case for much longer - when the Allowlists API is complete, IMA policies will live in their own separate table. It's a technical detail, but one worth keeping in mind.

Yes, thanks for pointing that out. Fortunately this change does not really affect this proposal because the IMA policy format does not require knowledge about the agent. The only thing is probably the some DB column names might change.

Most importantly, though, I agree with @lukehinds that we need to think carefully about how we want to approach signing before implementing the new policy format. We have an opportunity to future-proof that mechanism, and we should if we're making a breaking API change anyway. I don't see why that concern should block this enhancement from being merged, but I also think #79 should be merged before attempting implementation.

Fully agree. It makes sense to implement both proposals in one go.

Copy link
Contributor

@mbestavros mbestavros left a comment

Choose a reason for hiding this comment

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

I didn't realize I hadn't explicitly approved it, but I think this is ready to go!

@THS-on THS-on merged commit 06ea7ab into keylime:master Sep 27, 2022
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.

6 participants