-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Signature support in OPA bundles #1757
Comments
Great idea fams. I would probably like to suggest a couple of tweaks:
{
"payload": {
"bundle": {
"release": "release_19.232.212",
"files": [
{
"filename": "uam/rego/uam2-resources.rego",
"signature": "5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"revision": "2e162430f7bc93f35164a4ffe8ad0cb5c00c0a9a"
},
{
"filename": "uam/entitlements/uam-entitlements.json",
"signature": "cc8567d70002e957612902a8e985ea129d831ebe04057d88fb644857caa45d11",
"revision": "2e162430f7bc93f35164a4ffe8ad0cb5c00c0a9a"
},
{
"filename": "ldap/staff2groups.json",
"signature": "03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773",
"revision": "2e162430f7bc93f35164a4ffe8ad0cb5c00c0a9a"
}
]
}
},
"protected": {
"alg": "ES256"
},
"header": {
"signature": "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU01Q"
}
} |
A few quick thoughts around this.
This definitely needs more thought. |
Typically we see people build each bundle so all the files come from a single git hash (say) on master. The presence of the file in master ensures it has been approved by the correct people (since they merged it). The signature verification ensures that the bundle as a whole is coming from a trusted source. Are you imagining a bundle being built out of files from different repositories or different branches within the same repository? |
Thanks for the great feedback which I hope I've incorporated in this update.
{
"revision" : "7864d60dd78d748dbce54b569e939f5b0dc07486",
"roots": ["roles", "http/example/authz"],
"payload": {
"files": [
{
"filename": "uam/rego/uam2-resources.rego",
"sha-1": "5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"revision": "2e162430f7bc93f35164a4ffe8ad0cb5c00c0a9a"
},
{
"filename": "uam/entitlements/uam-entitlements.json",
"sha-1": "cc8567d70002e957612902a8e985ea129d831ebe04057d88fb644857caa45d11",
"revision": "3e162430f7bc93f35164a4ffe8ad0cb5c00c0a9b"
},
{
"filename": "ldap/staff2groups.json",
"sha-1": "03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773",
"revision": "4e162430f7bc93f35164a4ffe8ad0cb5c00c0a9c"
}
]
},
"protected": {
"alg": "ES256"
},
"header": {
"signature": "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU01Q"
}
} Once everyone has fed back I put together some examples to encode and decode... |
I think merging the manifests opens a problem of not being able to sign the .manifest itself. Hence, I'm still in favour of having the signatures outside of it. This keeps the signature envelope and the signed content clearly separated. I tend to think the inconsistency issues are more than resolvable within a single tar file. Also, per the JWS general syntax, most of the fields in the signature are base64 url encoded. This does include the payload field. Therefore, I would not place the file list under the "payload" field. This is to avoid confusion as that field could not be used as such for the validation anyway but it has to be base64 url encoded first. Fortunately, we don't have to include the base64 encoded version to the signature itself (per JOSE detached content mode). All and all, here's the ".signature" file the above results in:
I did consider also removing the digests from the file listing, because they don't really add anything to the security of the signature. Then would merely need a single top level "digest" property to indicate the cryptographic digest algorithm to use to compute digests for files. However, in the end, I convinced myself that having the digests with the files is nice since then the structure is exactly the payload to construct, base64 encode and pass for the signature validation. Sort of self-documenting. Note the support for multiple signatures. It is the validator's responsibility to check all the files are covered and no additional files are present. |
Thanks for the feedback guys. Following JOSE's/JWT's spec and JWS's compact serialization approach, one of the ways we discussed is OPA to support the verification of signed bundles (files/data) where signatures will essentially be compact, URL-safe, Base64 encodedJWT token. A sample JWT token is mentioned below.
Upon decoding, the sample header and claims would look like -
Claims:
OPA could have Here is the repository with POC code which has a simple Go and Java implementations to generate the JWT token and cross verify it - Please review it and share your thoughts. |
Two observations:
What do you think? |
Both the suggestions sound logical, thoughtful, and certainly feasible - let me have a quick discussion here and confirm you on that. A followup question on the point - 2 though: When you say |
With the second point, I was referring to the requirement to take the whole signature (all of its parts), and then needing to start unpacking it (whatever it entails) to get the claims out, only after which you can identify the files the signature is about. |
Alright, so per your suggestion, I've modified the POC a bit to produce
Upon decoding the signature, claims would look like something like this -
Does that aligns with your thoughts? |
Looking pretty much what I thought. One more thing: I think we can drop the "files" from the claims. Right? |
The files need to be inside the claim e.g.
If they are outside of the claim then anyone can change the files contents and update the SHA-256. So we only just need the compact serialized signature:
|
There's no security impact for the following reason. First, the |
Guys, as discussed previously, I've added CLI options to both, Go & Java, implementations of the POC code at opa-signature-poc. It currently has signing/verification approach for both asymmetric(RSA) and symmetric(HMAC) keys, however, it only uses the compact serialization approach. Signatures can be cross verified across Go and Java commands/implementations. README.md contains the list of commands and flags and rest is descriptive enough. Please take a look and try it out. We can discuss it in our next catchup. |
Just to add a bit more around
|
These changes add support for digital signatures for policy bundles which can be used to verify their authenticity. Bundle signature verification involves the following steps: * Verify the JWT signature * Verify the files in the JWT payload exist in the bundle * Verify the file content of the files in bundle match with those in the payload This commit adds a new `sign` command to generate a digital signature for policy bundles. For more details, run "opa sign --help" The signatures generated by the 'sign' command can be verified by the 'build' command. The 'build' command can also sign the bundle it generates. The 'run' command can verify a signed bundle or skip verification altogether. OPA 'sign', 'build' and 'run' can be used to sign/verify bundles in bundle mode (--bundle) mode only. Verification can be also be performed when bundle downloading is enabled. Fixes: open-policy-agent#1757 Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
These changes add support for digital signatures for policy bundles which can be used to verify their authenticity. Bundle signature verification involves the following steps: * Verify the JWT signature * Verify the files in the JWT payload exist in the bundle * Verify the file content of the files in bundle match with those in the payload This commit adds a new `sign` command to generate a digital signature for policy bundles. For more details, run "opa sign --help" The signatures generated by the 'sign' command can be verified by the 'build' command. The 'build' command can also sign the bundle it generates. The 'run' command can verify a signed bundle or skip verification altogether. OPA 'sign', 'build' and 'run' can be used to sign/verify bundles in bundle mode (--bundle) mode only. Verification can be also be performed when bundle downloading is enabled. Fixes: #1757 Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
OPA allows to store and download bundles from an https endpoint. To guarantee to avoid errors or malicious injections of rules or even data, to implement a form of signing of OPA bundles will be very likely.
It can be an extension of the dotManifest file with bundled files hash and an RSA signature of the object like in JOSE.
ex:
{
"revision": "7864d60dd78d748dbce54b569e939f5b0dc07486",
"roots": ["permissions", "istio/auth", "certificates"],
"validation": {
"files": [{
"filename": "/perms/data.json",
"sha-1": "974313a39889405a54d53d4f5083c541d1e101e4"
}, {
"filename": "/rules/rule.rego",
"sha-1": "5fa778fadccb8a48bb0bbc904d63179f24b031e7"
}],
"rs256": "UHNkNvv6ug-ZTzw8gPbVN3npmCmTH7wh7z4dfWMXUY67A0DQDRqaErURm1F7dgEk_vaekWfUTI1WgiTPgwu8guDRNz_eRluQYUh5cbfFhGCQraMC5Y5jQRqCtNd_Df4KTvuoy3zdmJPaK4QSSiaUwK1Lxf74Ek1SRGkyrGDiGp7dch_gwTGqhEGY2dtiM9TFO9ar1kK6nt9w1HT80_TLMM0Js2x7Kywgq4ZP8ARuu6j7nljJr6IBBAx_fooypEww71ucbXUk8AbiUBw-8eP_cmFnYjR-rUO9dYOH2smfhM1ZbQDRxIxL4QkxscHsEhdxHasKlRc0wmcpixLSDa7NrA"
}
}
The text was updated successfully, but these errors were encountered: