fix: restore report owner verification on Keycloak by using SA roles#279
fix: restore report owner verification on Keycloak by using SA roles#279rhartuv wants to merge 7 commits into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
/retest |
zvigrinberg
left a comment
There was a problem hiding this comment.
Hi @rhartuv
The idea is good, and it should work as expected.
Just one configuration trick, that will improve a lot the configuration maintainability .
Thank you.
There was a problem hiding this comment.
@rhartuv Use here property expression that will expand the property values into the list here ( instead of hard-coding the service account names one after another), in order to prevent maintenance burden of keeping the values aligned, which is error prone
quarkus.http.auth.policy.role-policy.roles-allowed=exploit-iq-view,exploit-iq-prodsec,exploit-iq-admin,${exploitiq.security.service-account-roles}
|
|
||
| # Service-account roles used to skip report owner verification (OIDC-provider agnostic). | ||
| # Outside exploit-iq.* AppConfig mapping so native builds do not bake unresolved ${NAMESPACE}. | ||
| # Keep in sync with the SA entries in role-policy.roles-allowed above. |
There was a problem hiding this comment.
@rhartuv This is redundant and just maintenance burden which is tend to be error prone
[See above] (#279 (comment))
zvigrinberg
left a comment
There was a problem hiding this comment.
@rhartuv
1 Final comment, PTAL.
Thank you.
| quarkus.rest-client.github.headers.User-Agent=exploit-iq | ||
| quarkus.rest-client.exploit-iq.url=https://exploit-iq:8080/generate | ||
| %dev.quarkus.rest-client.exploit-iq.url=http://localhost:26466/generate | ||
| %dev.NAMESPACE=local-dev |
There was a problem hiding this comment.
@rhartuv It's already defined here in development profile.
| exploitiq.security.service-account-roles=system:serviceaccounts:${NAMESPACE:local-dev}:exploit-iq-sa,system:serviceaccounts:${NAMESPACE:local-dev}:pipeline,exploitiq-api-access | ||
|
|
There was a problem hiding this comment.
@rhartuv You don't need the default for NAMESPACE env var expansion, as it's already defined in the development profile property entry in the configuration file for development purposes.
On cluster environments the NAMESPACE env var is always populated using the K8 Downward API' fieldRef facility/feature. ( it's getting the metadata.namespace value of the pod injected into this env var).
| exploitiq.security.service-account-roles=system:serviceaccounts:${NAMESPACE:local-dev}:exploit-iq-sa,system:serviceaccounts:${NAMESPACE:local-dev}:pipeline,exploitiq-api-access | |
| exploitiq.security.service-account-roles=system:serviceaccounts:${NAMESPACE}:exploit-iq-sa,system:serviceaccounts:${NAMESPACE}:pipeline,exploitiq-api-access | |
See #279 (comment)
zvigrinberg
left a comment
There was a problem hiding this comment.
@rhartuv LGTM Approved
|
|
||
| # Service-account roles (OIDC-provider agnostic): used for HTTP auth and to skip report owner verification. | ||
| # Outside exploit-iq.* AppConfig mapping so native builds do not bake unresolved ${NAMESPACE}. | ||
| exploitiq.security.service-account-roles=system:serviceaccounts:${NAMESPACE}:exploit-iq-sa,system:serviceaccounts:${NAMESPACE}:pipeline,exploitiq-api-access |
There was a problem hiding this comment.
@rhartuv Just found out now, this is a regression, it causing 403 on environment.
| exploitiq.security.service-account-roles=system:serviceaccounts:${NAMESPACE}:exploit-iq-sa,system:serviceaccounts:${NAMESPACE}:pipeline,exploitiq-api-access | |
| exploitiq.security.service-account-roles=system:serviceaccount:${NAMESPACE}:exploit-iq-sa,system:serviceaccount:${NAMESPACE}:pipeline,exploitiq-api-access |
There was a problem hiding this comment.
Sorry, my bad. Fixing
There was a problem hiding this comment.
@rhartuv There was a more deep cause (beyond that) , I've fixed it...
There was a problem hiding this comment.
I will rebase after you merge
There was a problem hiding this comment.
@rhartuv It merged ( #281) , you can rebase.
afterwards, Kindly test on your cluster environment ( eiq-rht ) using the temporary pr image tag, to see it goes well with a simple invocation of an analysis ( DOD -> agent-> client communication is valid and works as expected, the result sent correctly from agent to client , and shown in UI).
Thank you!
There was a problem hiding this comment.
afterwards, Kindly test on your cluster environment ( eiq-rht ) using the temporary pr image tag, to see it goes well with a simple invocation of an analysis ( DOD -> agent-> client communication is valid and works as expected, the result sent correctly from agent to client , and shown in UI).
Done
37e27d9 to
cb6b1dc
Compare
Summary
POST /api/v1/reports/failedowner verification on Keycloak (external-idp): stop usinginstanceof JsonWebTokento tell humans from service accounts.exploitiq.security.service-account-roles), so ownership checks work across OpenShift OAuth and Keycloak.ReportServiceAuditTest.Problem
requiresOwnerVerification()treated any JWT principal as a service account. That works on OpenShift OAuth (only SAs use JWTs), but on Keycloak both humans and SAs use JWTs — so owner verification was skipped for everyone, and any authenticated user could mark another user's reports as failed.Fix
Replace JWT-type coupling with a role check against configured service-account roles (
@ConfigProperty, outside theexploit-iq.*AppConfigmapping so native builds do not resolve${NAMESPACE}at image-build time):system:serviceaccounts:${NAMESPACE}:exploit-iq-sa,...:pipelineexploitiq-api-accessHuman callers still require
metadata.userto match the actor; SA-role callers skip ownership checks.Jira