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

CDPT-2079 Focus first new result after (infinite) pagination. #744

Merged
merged 5 commits into from
Oct 30, 2024

Conversation

EarthlingDavey
Copy link
Contributor

No description provided.

@EarthlingDavey EarthlingDavey marked this pull request as draft October 17, 2024 14:15
@EarthlingDavey EarthlingDavey marked this pull request as ready for review October 17, 2024 14:24
Copy link
Contributor

@wilson1000 wilson1000 left a comment

Choose a reason for hiding this comment

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

Nice :) do we need to worry about the .append() function reinterpreting text as HTML?

@EarthlingDavey
Copy link
Contributor Author

Hey @wilson1000 , I've double and triple checked and I think it's ok.

With .append and .html that have been flagged, the html content is trusted and has come from the server.

AFAICT, there is no opportunity for an attacker to get their own content into the parameters.

From my understanding this is bad:

# Get the id form the url, e.g. example.com#15
const pageNumber = window.location.hash;
# Make a html string
const html = `<p>You are on page number ${pageNumber}`
# Append the html
$("#content").append(html);

Because someone could visit example.com#<script>alert('pwned')</script> , and it would run the js.

But I think it's safe to do the following:

$.ajax({
  success: (response) => {
    // Transform the response... without using untrusted user inputs.
    // ...
    // Use .append with trusted html
    $("#content").append(response.html);
   }
});

@wilson1000
Copy link
Contributor

But I think it's safe to do the following:

Hey @EarthlingDavey - can a user intercept the request before the server responds, or do we have complete trust that the server gave us the response and not another service?

I hope that made sense, and sorry for being (probably) catastrophic in my thinking!

@EarthlingDavey
Copy link
Contributor Author

I think it's possible that a user could manipulate requests, but all $_POST data is being sanitized in content-filter/search.php with sanitize_text_field.

This sanitization prevents 'reflected' xss attacks.

But, I've learned recently that 'stored' xss attacks can happen when a script tag that's stored in the database makes it's way into the DOM, because of insufficient escaping at render time.

I'll look into it, to see if this script is vulnerable to that kind of attack.

@EarthlingDavey EarthlingDavey merged commit 0cada6d into develop Oct 30, 2024
6 checks passed
@EarthlingDavey EarthlingDavey deleted the bug/cdpt-2079-focus-new-result-on-pagination branch October 30, 2024 15:34
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.

2 participants