Skip to content

Improve UI5Xss.ql query to detect default OData model with bindElement#283

Merged
data-douser merged 5 commits intomainfrom
dd/default-odata-model-fragments
Jan 27, 2026
Merged

Improve UI5Xss.ql query to detect default OData model with bindElement#283
data-douser merged 5 commits intomainfrom
dd/default-odata-model-fragments

Conversation

@data-douser
Copy link
Copy Markdown
Collaborator

What This PR Contributes

This pull request improves the detection of XSS vulnerabilities in SAP UI5 applications by enhancing the binding analysis logic and adding a comprehensive test case for scenarios involving fragments and default OData models. The main changes include refining how context bindings via bindElement are tracked, updating the logic for identifying default model usage, and introducing a new test suite to validate the detection of XSS in this context.

Outline of Changes

Key improvements include:

Improvements to OData Default Model Binding Detection:

  • Added a new method getBindElementCall() to the Binding class to accurately retrieve the bindElement method call node for context bindings.
  • Updated the asBinding() method in DefaultODataServiceModel to match context bindings whose bindElement call is this node, improving the association between the model and its bindings.
  • Refined the logic in UI5BindingPath to only consider setModel calls within the same webapp, preventing false associations with unrelated models.

New Test Case for XSS Vulnerability:

  • Added a complete test scenario (xss-fragment-odata-default-model) demonstrating an XSS vulnerability when a fragment is bound to an OData entity via the default model and displays unsanitized data. This includes all necessary configuration, controller, fragment, and manifest files. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

The setModel check in UI5BindingPath.getASource() was globally scoped, causing
detection to fail when apps with explicit setModel calls were in the same
database as apps using default OData models from manifest.json.

Changes:
- Bindings.qll: Add getBindElementCall() method to Binding class
- RemoteFlowSources.qll: Fix DefaultODataServiceModel.asBinding() to use
  getBindElementCall() for proper context binding matching
- UI5View.qll: Scope setModel check to same webapp using inSameWebApp()
- Add test case xss-fragment-odata-default-model validating the fix

All 26 UI5Xss tests pass.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances the detection of XSS vulnerabilities in SAP UI5 applications by improving how context bindings via bindElement are tracked when using default OData models. The changes refine the query logic to more accurately identify when fragments bound to OData entities through the default model contain XSS vulnerabilities.

Changes:

  • Added getBindElementCall() method to retrieve the bindElement call node from context bindings
  • Fixed DefaultODataServiceModel.asBinding() to correctly match bindings by their bindElement call
  • Refined model resolution logic to only consider setModel calls within the same webapp
  • Added comprehensive test case demonstrating XSS vulnerability detection with fragments and default OData models

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

File Description
javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/Bindings.qll Added getBindElementCall() method to extract bindElement call from context bindings
javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/RemoteFlowSources.qll Fixed DefaultODataServiceModel.asBinding() to correctly match bindings using the new method
javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/UI5View.qll Refined model resolution to only check setModel calls in same webapp
javascript/frameworks/ui5/test/queries/UI5Xss/xss-fragment-odata-default-model/* Complete test case with manifest, controllers, views, fragments, and expected results

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@data-douser data-douser marked this pull request as ready for review January 23, 2026 21:31
Copy link
Copy Markdown
Contributor

@knewbury01 knewbury01 left a comment

Choose a reason for hiding this comment

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

lgtm! thanks!

This commit:

- fixes cross-app isolation for the edge case where multiple
  UI5 apps are under the same "source-root" directory -- and
  are therefore analyzed via the same CodeQL database -- while
  also using the default OData model via bindElement.

- adds expected js/ui5-xss results for the new xss-cross-app-isolation
unit test:
  - webapp_a/fragments/DataDisplay.fragment.xml (line 7)
  - webapp_b/fragments/DataDisplay.fragment.xml (line 7)

These results validate that the improved DefaultODataServiceModel class
correctly isolates XSS detection within webapp boundaries when using
default OData models with bindElement.
Copy link
Copy Markdown
Contributor

@knewbury01 knewbury01 left a comment

Choose a reason for hiding this comment

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

re-reviewed and looks good to me! thanks!

@data-douser data-douser merged commit 00575e7 into main Jan 27, 2026
5 checks passed
@data-douser data-douser deleted the dd/default-odata-model-fragments branch January 27, 2026 19:37
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.

4 participants