From c7f59d62064ccfb9f71e9db8b1e139b355310564 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Wed, 2 Sep 2015 14:14:02 +0200 Subject: [PATCH] Prevent XSS by escaping user input Additionally, escape "'s so no attributes can be inserted into webpages. Thanks to Pierre Jaury and Damien Cauquil at Sysdream for pointing this out. --- pdns/ws-auth.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 9ad8efebe..9629fb2cb 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -122,6 +122,9 @@ static string htmlescape(const string &s) { case '>': result += ">"; break; + case '"': + result += """; + break; default: result += *it; } @@ -141,15 +144,15 @@ void printtable(ostringstream &ret, const string &ringname, const string &title, } ret<<"
"; - ret<<"Reset"<Reset"<"<"<"; - ret<<"Showing: Top "<"<Showing: Top "<"<Resize: "; unsigned int sizes[]={10,100,500,1000,10000,500000,0}; for(int i=0;sizes[i];++i) { if(S.getRingSize(ringname)!=sizes[i]) - ret<<""< "; + ret<<""< "; else ret<<"("<