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

fix: enforce app create/update privileges when getting repo details #8558

Merged
merged 5 commits into from Feb 22, 2022

Conversation

jessesuen
Copy link
Member

When getting repo details for an app, we will now require the user to specify both the project + app name for which it wants to create it or update. This ensures that we only return details about the repo if the user has permission to create/update the app.

Signed-off-by: Jesse Suen jesse@akuity.io

@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #8558 (9ba37cb) into master (53090f1) will increase coverage by 0.19%.
The diff coverage is 90.24%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8558      +/-   ##
==========================================
+ Coverage   42.41%   42.60%   +0.19%     
==========================================
  Files         176      176              
  Lines       22904    22941      +37     
==========================================
+ Hits         9714     9774      +60     
+ Misses      11804    11770      -34     
- Partials     1386     1397      +11     
Impacted Files Coverage Δ
server/repository/repository.go 52.44% <89.74%> (+16.04%) ⬆️
server/server.go 55.41% <100.00%> (+0.08%) ⬆️
util/settings/settings.go 47.91% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53090f1...9ba37cb. Read the comment docs.

server/repository/repository.go Outdated Show resolved Hide resolved
server/repository/repository.go Show resolved Hide resolved
@jessesuen
Copy link
Member Author

@alexmt I brought the ProjectLister into the repositories grpc server and it now verifies permitted sources when returning repo details.

@alexmt
Copy link
Collaborator

alexmt commented Feb 18, 2022

Just so we don't forget: as we discussed offlinethe same projection is required for POST /appdetails API.

@alexmt alexmt added this to the v2.3 milestone Feb 18, 2022
@jessesuen jessesuen force-pushed the fix-enforce-app-privileges branch 2 times, most recently from 874fd74 to f5abc72 Compare February 22, 2022 20:07
Signed-off-by: Jesse Suen <jesse@akuity.io>
Signed-off-by: Jesse Suen <jesse@akuity.io>
Signed-off-by: Jesse Suen <jesse@akuity.io>
Signed-off-by: Jesse Suen <jesse@akuity.io>
@jannfis
Copy link
Member

jannfis commented Feb 22, 2022

Is this a potentially breaking change in the API, when previously it was not required to specify both app name and app project? Can't we infer the project from the application's .spec.project field?

@jessesuen
Copy link
Member Author

jessesuen commented Feb 22, 2022

Is this a potentially breaking change in the API, when previously it was not required to specify both app name and app project? Can't we infer the project from the application's .spec.project field?

Yes, it is a breaking change. That said, since this is a UI-only endpoint, they would only need to refresh the page in their browser and that would fix the issue.

Can't we infer the project from the application's .spec.project field?

We can only do this if the app exists, but not when this endpoint is called during app creation, which is what we also need to fix. In the case where app already exists, I do have a check to make sure the supplied project in the request matches app.spec.project and returns permission denied if they mismatch.

Signed-off-by: Jesse Suen <jesse@akuity.io>
@jannfis
Copy link
Member

jannfis commented Feb 22, 2022

Yes, it is a breaking change. That said, since this is a UI-only endpoint, they would only need to refresh the page in their browser and that would fix the issue.

I'm not quite sure if I go along the notation of UI only endpoints. It's in the public part of the API, potentially used by people who build their own UI for Argo CD (or use the endpoint otherwise from their clients).

Anyhow, I think this change justifies the breakage. IMHO, we should point it out in the release notes that there has been a small breaking change without alternative to being breaking, and users consuming this API endpoint for whatever reason need to adapt their clients.

Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

LGTM

return nil, errPermissionDenied
}
// verify caller is not making a request with arbitrary source values which were not in our history
if !isSourceInHistory(app, *q.Source) {
Copy link
Collaborator

@alexmt alexmt Feb 22, 2022

Choose a reason for hiding this comment

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

Great catch. I totally forgot about sync history use case.

Copy link
Collaborator

@alexmt alexmt left a comment

Choose a reason for hiding this comment

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

LGTM. I agree security patch is good justification for a breaking API change.

Copy link
Collaborator

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

LGTM!

@jessesuen jessesuen merged commit ac47a42 into argoproj:master Feb 22, 2022
@jessesuen jessesuen deleted the fix-enforce-app-privileges branch February 22, 2022 22:02
gdsoumya pushed a commit to gdsoumya/argo-cd that referenced this pull request Feb 23, 2022
alexmt pushed a commit that referenced this pull request Feb 25, 2022
alexmt pushed a commit that referenced this pull request Mar 3, 2022
alexmt pushed a commit that referenced this pull request Mar 4, 2022
wojtekidd pushed a commit to wojtekidd/argo-cd that referenced this pull request Apr 25, 2022
…rgoproj#8558)

Signed-off-by: Jesse Suen <jesse@akuity.io>
Signed-off-by: wojtekidd <wojtek.cichon@protonmail.com>
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.

None yet

4 participants