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

[BUG] Unencoded Content in Search Leads to JavaScript Execution Risk in autocomplete-js #416

Closed
wjhwjhn opened this issue Feb 16, 2024 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@wjhwjhn
Copy link

wjhwjhn commented Feb 16, 2024

Describe the bug 描述你遇到的错误

When performing a search, if the previewed article contains <script> tags, passing it to autocomplete-js results in the execution of the script.

Expected behavior 期待的行为

Before adding the <${highlightTag}> markers, encode the article content using the encodeURIComponent function.
Reference location: theme.js L237

Screenshots 屏幕截图

Follow the steps to reproduce and alert box pops up displaying "1".
image
The location that causes code execution, in autocomplete-js
image

Build Environment 构建环境

  • OS: Ubuntu
  • Theme commit: v0.3.2-RC
  • Hugo version: v0.122.0

Preview Environment 预览环境

No response

Additional Information 补充信息

Steps to Reproduce

  1. Insert an article containing a <script> tag. For example:

    # TEST
    
    ```html
    <script>
     alert("1");   
    </script>
    ```
  2. Search for "TEST" within the article.

  3. A browser alert box pops up displaying "1".

@wjhwjhn wjhwjhn added the bug Something isn't working label Feb 16, 2024
@Lruihao Lruihao self-assigned this Apr 25, 2024
@Lruihao Lruihao added this to the v0.3.x milestone Apr 25, 2024
@Lruihao Lruihao moved this from To do to Done in Roadmap of FixIt Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants