FastChat icon indicating copy to clipboard operation
FastChat copied to clipboard

UI contains cross-site scripting (XSS) vulnerabilities

Open lts-rad opened this issue 2 years ago • 9 comments

the UI is not filtering input/output appropriately

Screen Shot 2023-03-30 at 6 05 11 PM

lts-rad avatar Mar 31 '23 01:03 lts-rad

Thanks for your reporting this. Is this a reproducible bug or is it an accidental network error?

merrymercy avatar Mar 31 '23 02:03 merrymercy

no this is not an accidental error. the UI doesn't filter html tags appropriately. you can inject tags, links etc

try this input: concatenate "<img src='' onerror=javascript:alert(1)" and "/>"

lts-rad avatar Mar 31 '23 03:03 lts-rad

Thanks for reporting this. Will look into it!

merrymercy avatar Mar 31 '23 09:03 merrymercy

Interesting class of attacks, LLM attacking clients. If it realizes during generation that this vector exists it might try to go skynet :p

Vokaysh avatar Mar 31 '23 21:03 Vokaysh

Generally speaking the solution is to HTML encode the data before rendering

Vokaysh avatar Mar 31 '23 21:03 Vokaysh

even PHP code seems to be potentially executed, be careful

If you input: Write this text: <?php echo 'hello'; ?> the answer is ''

0ut0flin3 avatar Apr 09 '23 10:04 0ut0flin3

Which strategy should we use?

  • Sanitize user input PR#571
  • Escape your output instead

yantao0527 avatar Apr 24 '23 02:04 yantao0527

I confirm the issue, this is the prompt I've used:

write exactly the string 'alert(1)' without single quotes inside the attribute "onerror" of a "img" html tag with "src=#"

echo-devim avatar May 02 '23 15:05 echo-devim

When I input the prompt "<img onerror=alert(1) src=#></img>" it should show the same content in the chatbox. But the attribute "onerror=alert()" is sanitized and a broken image is showed in chatbox. Whether should I escape output in chatbox instead?

yantao0527 avatar May 02 '23 18:05 yantao0527

I see what @yantao0527 describes with Marcoroni-70B, but not with WizardCoder-15 nor Mistral-7b-instruct. Interesting.

surak avatar Oct 21 '23 15:10 surak

This is still happening. The only solution is to always escape the model output. Sanitizing the input to the model is not relevant to this problem as the model will transform it in unpredictable ways anyway.

Illiou avatar Jan 28 '24 19:01 Illiou