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

Abp.Sanitizer can cause a model binding validation bypass #6750

Open
antheus-s opened this issue Jul 24, 2023 · 5 comments
Open

Abp.Sanitizer can cause a model binding validation bypass #6750

antheus-s opened this issue Jul 24, 2023 · 5 comments
Assignees
Milestone

Comments

@antheus-s
Copy link
Contributor

When using the Abp.Sanitizer package (any version), sanitization happens after validation in the pipeline. Which means that if I have a dto with a [Required] property, and also want to sanitize the input, and my input is "<script>test</script>", the value after sanitization will be empty. This means that it bypasses the validation.

@ismcagdas
Copy link
Member

I couldn't be sure if we execute sanitization before validation.

@antheus-s
Copy link
Contributor Author

The easiest way to test this would be to have a dto with a required property and to add the HtmlSanitizerAttribute to the method in the app service that uses the dto for input. The value should be something like "<script>test</script>", which, after sanitization, will be "". Even though the property has the RequiredAttribute, the method will be accessible and validation is skipped.

If my explanation is not clear, I can also make an example.

@ismcagdas
Copy link
Member

No, it is totally clear. I'm just thinking about this from different angles :)

@antheus-s
Copy link
Contributor Author

Ah ok :P

@ismcagdas ismcagdas added this to the Backlog milestone Oct 9, 2023
@ismcagdas ismcagdas modified the milestones: Backlog, v9.2 Feb 7, 2024
@ismcagdas ismcagdas modified the milestones: v9.2, v9.3 Apr 24, 2024
@quocduong
Copy link

More case
Input: <div STYLE="width: expression(alert('XSS'));">
Output: encode html format

This output will make the HTML form work incorrectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants