-
Notifications
You must be signed in to change notification settings - Fork 2
Implement UnnecessarilyGrantedPrivilegedAccessRights
#139
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
Conversation
…leged -access-rights
UnnecessarilyGrantedPrivilegedAccessRights
...rks/cap/src/bad-authn-authz/DynamicallyGeneratedPrivileged/DynamicallyGeneratedPrivileged.md
Outdated
Show resolved
Hide resolved
...rks/cap/src/bad-authn-authz/DynamicallyGeneratedPrivileged/DynamicallyGeneratedPrivileged.ql
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a first review and left a few comments
...thz/UnnecessarilyGrantedPrivilegedAccessRights/UnnecessarilyGrantedPrivilegedAccessRights.md
Outdated
Show resolved
Hide resolved
...hn-authz/misused-privileged-user/unnecessarily-granted-privileged-access-rights/package.json
Outdated
Show resolved
Hide resolved
...thz/UnnecessarilyGrantedPrivilegedAccessRights/UnnecessarilyGrantedPrivilegedAccessRights.ql
Outdated
Show resolved
Hide resolved
...thz/UnnecessarilyGrantedPrivilegedAccessRights/UnnecessarilyGrantedPrivilegedAccessRights.ql
Outdated
Show resolved
Hide resolved
...t/queries/bad-authn-authz/entities-with-no-authz/entities-exposed-with-no-authz/package.json
Outdated
Show resolved
Hide resolved
…ntedPrivilegedAccessRights/UnnecessarilyGrantedPrivilegedAccessRights.ql Co-authored-by: Mauro Baluda <[email protected]>
…om:advanced-security/codeql-sap-js into jeongsoolee09/fix-package-json-assumptions
return this.tx( | ||
{ user: new cds.User.Privileged("privileged-user-4") }, | ||
(tx) => | ||
tx.run( | ||
SELECT.from(Service2Entity1) // Declared in service2.cds | ||
SELECT.from(Service2Entity2) // Declared in service2.cds |
Check warning
Code scanning / CodeQL
Access rights to an entity is unnecessarily elevated to privileged Medium test
{ user: new cds.User.Privileged("privileged-user-5") }, | ||
(tx) => | ||
tx.run( | ||
SELECT.from`RemoteEntity` // Assume that it's declared in @example/sample | ||
SELECT.from`RemoteEntity` // Assume that it's declared in @advanced-security/remote-service |
Check warning
Code scanning / CodeQL
Access rights to an entity is unnecessarily elevated to privileged Medium test
tx.run( | ||
INSERT.into("Service2Entity").entries({ | ||
INSERT.into("Service2Entity2").entries({ |
Check warning
Code scanning / CodeQL
Access rights to an entity is unnecessarily elevated to privileged Medium test
tx.run( | ||
INSERT.into("Service2Entity").entries({ | ||
INSERT.into("Service2Entity2").entries({ |
Check warning
Code scanning / CodeQL
Access rights to an entity is unnecessarily elevated to privileged Medium test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it! 🚀
What this PR contributes
This PR aims to:
cds.requires
in test cases: previouslycds.requires
hadservice-1
andservice-2
.Adding UnnecessarilyGrantedPrivilegedAccessRights
This query was previously named DynamicallyGeneratedPrivileged but renamed to UnnecessarilyGrantedPrivilegedAccessRights to better illustrate its core concerns: the fact that a privileged user is dynamically generated is itself not a problem, but that it's used to grant elevated access rights is.
UnnecessarilyGrantedPrivilegedAccessRights aims to find transactions that accesses an entity which requires nontrivial access rights (i.e. not trivial ones such as
@(restrict: [{grant: 'READ'}])
) in the context ofcds.User.Privileged
. This is a powerful role that bypasses all authorization checks that may be abused in the real world; a programmer may wish to access local entities without restrictions since they can already be accessed by other services in the same application. However, from the perspective of authorization this is an unnecessarily elevated access right and therefore a mistake in access control.Fixing wrong assumptions
cds.requires
inpackage.json
of each test case inbad-authn-authz
hadservice-1
andservice-2
that pointed to the implementation details:and the name
"service-1"
and"service-2"
were used as handles to connect to the associated service:However, some back-and-forth with a CAP expert from SAP revealed that this is not only necessary but wrong in some cases. Therefore, this PR remove such
cds.requires
section and changes the argument"service-2"
to"Service2"
, to directly reference the service without an intermediary handle.Others
CDS.qll
to makeServiceInstance
a subclass ofDataFlow::SourceNode
, notDataFlow::Node
, and use it to simplify all cases ofServiceInstance
as well as its key member predicategetASrvMethodCall
. Move this member predicate to the abstract class level.CDS.qll
by moving type trackers into their own module.EntityReference
that models references to entities which are either variables containing a value of a property ofsrv.entities
, or string/template literals which resolve to the entity:Service1.Service1Entity1
.