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

False positive 'abc < abcd' #134

Open
timmit-nl opened this issue Nov 3, 2023 · 3 comments
Open

False positive 'abc < abcd' #134

timmit-nl opened this issue Nov 3, 2023 · 3 comments

Comments

@timmit-nl
Copy link

timmit-nl commented Nov 3, 2023

We conducted a pentest on our software and this was a false positive that came out:

What is this feature about (expected vs actual behaviour)?

If there is a < followed by a-z it is changed by xss_clean to for example: 'test1 < test2' becomes: 'test1 &lt; test2'
But 'test1 > test2' will stay 'test1 > test2'

How can I reproduce it?

$test = 'test1 < test2';

$antiXSS = new \voku\helper\AntiXSS();

$testResult = $antiXSS->xss_clean($test);

if($test!==$testResult){
    echo 'failed';
}
if($antiXSS->isXssFound()){
    echo 'false positive';
}

Does it take minutes, hours or days to fix?

I really don't know, If I understand the packages better I maybe could write a fix, but I don't know where to start...

Any additional information?

@Loafy-wb
Copy link

I'm having the same issue.

For example <p>test1 < test2</p> is turned into <p>test1 &lt; test2&lt;/p&gt;

It seems to come from the _close_html_callback function and it assumes the < is the start of an HTML tag, so everything after is encoded. So in this case, it thinks there's an HTML tag < test2</p>

@Loafy-wb
Copy link

After checking other issues, this appears to be similar to #83 but the fix mentioned there does not seem to fix this for me.

With the update in this commit mathiasselleslach@2a65b16, it does change the result slightly for me but it doesn't solve the issue.

Now <p>test1 < test2</p> is turned into <p>test1 < test2&lt;/p>, which is closer but still not fixed

@voku
Copy link
Owner

voku commented Nov 14, 2023

I am not sure if we should fix it here. Maybe we can use a dom parser (e.g. https://github.com/voku/simple_html_dom/blob/master/tests/HTML5DOMDocumentTest.php) and auto correct the given html? 🤔

Result of the w3c validation:

Error: Bad character   after <. Probable cause: Unescaped <. Try escaping it as &lt;.

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

No branches or pull requests

3 participants