Summary
This issue tracks identified gaps in CodeQL library modeling and security queries for the SAP Cloud Application Programming (CAP) framework. Analysis is based on the CAP framework documentation, existing implementation in javascript/frameworks/cap/, and review of merged CAP PRs and merged CDS PRs.
Identified Gaps
Authentication & Authorization Patterns
Draft Handling
Transaction Management
OData Protocol Features
CAP-Specific Data Operations
CDS Annotations Security
Advanced Data Flow
Database-Specific Patterns
Messaging & Events
API Gateway & BTP Integration
Completed Work
Recent CAP modeling enhancements (see merged PRs):
Query Enhancements:
Modeling Improvements:
Framework-Specific Configuration:
CDS Extractor Enhancements:
Currently Modeled:
- Event handlers:
srv.on, srv.before, srv.after
- Remote flow sources:
req.data, req.params, req.headers, req.id, req._queryOptions, req.http.req.*
- Service patterns: ES6 class extension,
cds.service.impl(), exported closure
- Service exposure:
@path annotation detection, protocol: 'none' filtering
- CQL fluent API: SELECT, INSERT, UPDATE, DELETE, UPSERT
- CDS annotations:
@restrict, @requires (for authorization)
- CDS definition parsing: entities, events, actions, functions
Implementation Notes
For new gaps:
- Follow Test-Driven Development methodology
- Reference CAP framework development prompt for detailed patterns
- Use javascript-cap-modeling-agent for implementation
- Consult CAP documentation for authoritative behavior
- Add tests to
javascript/frameworks/cap/test/ with .expected files
Priority should be given to gaps that:
- Are commonly exploited in CAP applications
- Have high impact on security posture
- Are currently not detected by out-of-box CodeQL queries
References
Summary
This issue tracks identified gaps in CodeQL library modeling and security queries for the SAP Cloud Application Programming (CAP) framework. Analysis is based on the CAP framework documentation, existing implementation in
javascript/frameworks/cap/, and review of merged CAP PRs and merged CDS PRs.Identified Gaps
Authentication & Authorization Patterns
req.user.token, JWT validation flows, and token forwarding in service-to-service callsreq.user.id,req.user.attr, and session-based authentication patternsNonProductionStrategyUsed.qlDraft Handling
@odata.draft.enabledentity annotations and draft state transitionsTransaction Management
cds.tx()and transaction boundary creationOData Protocol Features
$filter,$orderby,$expand,$selectparameters as potential injection points$batchendpoint processing and batch request parsing$metadataendpointsCAP-Specific Data Operations
.cdsfilesCDS Annotations Security
@assert.range,@assert.format,@mandatoryfor sanitization@readonlyenforcement - Detect violations of read-only annotations@cds.on.insert/@cds.on.update- Model annotation-based lifecycle hooks@PersonalData,@PersonalData.IsPotentiallySensitivefor privacy complianceAdvanced Data Flow
Database-Specific Patterns
cds.run(),cds.db.run()with raw SQLMessaging & Events
API Gateway & BTP Integration
Completed Work
Recent CAP modeling enhancements (see merged PRs):
Query Enhancements:
cds.utilsfile operations (Add CDS Utils path injection query #224)Modeling Improvements:
RemoteFlowSourceof CAP to only some properties and method calls on it #208)Framework-Specific Configuration:
isSinkin the taint tracking configurations of the default queries #180)CDS Extractor Enhancements:
getCdsDeclaration()(Address a performance regression in recent upgrade #177)cds compilecommand usage (Runcds compilecommand without-ooption #172)codeql/javascript-alland fix breaking changes #170)Currently Modeled:
srv.on,srv.before,srv.afterreq.data,req.params,req.headers,req.id,req._queryOptions,req.http.req.*cds.service.impl(), exported closure@pathannotation detection,protocol: 'none'filtering@restrict,@requires(for authorization)Implementation Notes
For new gaps:
javascript/frameworks/cap/test/with.expectedfilesPriority should be given to gaps that:
References