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

sanitize submission result #1330

Merged
merged 15 commits into from
Oct 7, 2019
Merged

sanitize submission result #1330

merged 15 commits into from
Oct 7, 2019

Conversation

rien
Copy link
Member

@rien rien commented Sep 30, 2019

This pull request sanitizes submission results (i.e. we prevent additional <script> in judge output from being executed).

TODO:

Fixes #1139.

@rien rien added the WIP label Sep 30, 2019
@pdawyndt pdawyndt changed the title Sanitize submission result sanitize submission result Sep 30, 2019
@chvp chvp force-pushed the feature/sanitize-submission-result branch from c9b0546 to 5c2d7bf Compare October 5, 2019 09:47
@codecov
Copy link

codecov bot commented Oct 5, 2019

Codecov Report

Merging #1330 into develop will increase coverage by 1.59%.
The diff coverage is 100%.

@@             Coverage Diff             @@
##           develop    #1330      +/-   ##
===========================================
+ Coverage    82.18%   83.78%   +1.59%     
===========================================
  Files           89       89              
  Lines         4154     4156       +2     
===========================================
+ Hits          3414     3482      +68     
+ Misses         740      674      -66
Impacted Files Coverage Δ
app/helpers/renderers/pythia_renderer.rb 93.93% <100%> (+39.67%) ⬆️
app/helpers/renderers/lcs_html_differ.rb 63.48% <100%> (ø) ⬆️
app/helpers/renderers/feedback_table_renderer.rb 92.55% <100%> (+1.9%) ⬆️
app/helpers/application_helper.rb 85.58% <100%> (ø) ⬆️
app/models/concerns/cacheable.rb 83.33% <0%> (-16.67%) ⬇️

@chvp chvp added the feature New feature or request label Oct 5, 2019
@chvp chvp marked this pull request as ready for review October 5, 2019 11:26
@chvp chvp requested a review from bmesuere October 5, 2019 11:26
@chvp chvp added this to the 3.1 milestone Oct 5, 2019
Copy link
Member

@bmesuere bmesuere left a comment

Choose a reason for hiding this comment

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

Don't we need a test where the actual stripping is tested? For example, for the script tag, we want the tag + contents gone and not only the tag itself.

@chvp
Copy link
Member

chvp commented Oct 5, 2019

Note: we get deprecation warnings because of this but it should be fixed in the next version of rails-html-sanitizer.

@chvp chvp force-pushed the feature/sanitize-submission-result branch from 1dfbd95 to 03effe1 Compare October 5, 2019 13:08
@chvp
Copy link
Member

chvp commented Oct 5, 2019

I've added tests for and fixed the stripping of the content of tags in d13c4ee. It's quite hard to test this in the tests of the renderers though, since we actually want to escape most of the HTML in the JSON (e.g. in the diff table), which means the content will still be there (escaped, but otherwise unchanged).

@chvp chvp requested a review from bmesuere October 5, 2019 13:13
@chvp chvp removed the WIP label Oct 5, 2019
@chvp chvp force-pushed the feature/sanitize-submission-result branch from 03effe1 to d13c4ee Compare October 5, 2019 15:32
@chvp chvp merged commit ba5763c into develop Oct 7, 2019
@chvp chvp deleted the feature/sanitize-submission-result branch October 7, 2019 08:27
"generated": "<script>alert('Your mother was a hamster and your father smelt of elderberries.')</script>"
"accepted": false,
"description": "test whether the user can XSS",
"expected": "<script>alert('Your mother was a hamster and your father smelt of elderberries.')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script><script>alert('test')</script>",
Copy link
Member Author

Choose a reason for hiding this comment

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

👍

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

Successfully merging this pull request may close these issues.

XSS risks from untrusted exercise sources
3 participants