Skip to content

Commit

Permalink
Two vunlerability fixes:
Browse files Browse the repository at this point in the history
    - Fix #9095 XSS vulnerability
    - Fix #5094 DoS vulnerability
  • Loading branch information
Koen Deforche committed Jul 13, 2016
1 parent 448ccbf commit 95b2ad9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions examples/wt-homepage/Home.C
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ WString Home::tr(const char *key)

void Home::googleAnalyticsLogger()
{
doJavaScript("if (window.ga) ga('send','pageview','"
+ environment().deploymentPath() + internalPath() + "');");
doJavaScript("if (window.ga) ga('send','pageview',"
+ WWebWidget::jsStringLiteral(environment().deploymentPath()
+ internalPath()) + ");");
}

9 changes: 7 additions & 2 deletions src/web/WebRenderer.C
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ WebRenderer::WebRenderer(WebSession& session)
pageId_(0),
expectedAckId_(0),
scriptId_(0),
ackErrs_(0),
linkedCssCount_(-1),
currentStatelessSlotIsActuallyStateless_(true),
formObjectsChanged_(true),
Expand Down Expand Up @@ -211,10 +212,12 @@ bool WebRenderer::ackUpdate(int updateId)
LOG_DEBUG("jsSynced(false) after ackUpdate okay");
setJSSynced(false);
++expectedAckId_;
ackErrs_ = 0;
return true;
} else if ((updateId < expectedAckId_ && expectedAckId_ - updateId < 5)
|| (expectedAckId_ - 5 < updateId)) {
return true; // That's still acceptible but no longer plausible
++ackErrs_;
return ackErrs_ < 3; // That's still acceptible but no longer plausible
} else
return false;
}
Expand Down Expand Up @@ -342,6 +345,7 @@ void WebRenderer::streamBootContent(WebResponse& response,
bootJs.setVar("SESSION_ID", session_.sessionId());

expectedAckId_ = scriptId_ = WRandom::get();
ackErrs_ = 0;

bootJs.setVar("SCRIPT_ID", scriptId_);
bootJs.setVar("RANDOMSEED", WRandom::get());
Expand All @@ -351,7 +355,7 @@ void WebRenderer::streamBootContent(WebResponse& response,
bootJs.setVar("AJAX_CANONICAL_URL",
safeJsStringLiteral(session_.ajaxCanonicalUrl(response)));
bootJs.setVar("APP_CLASS", "Wt");
bootJs.setVar("PATH_INFO", WWebWidget::jsStringLiteral
bootJs.setVar("PATH_INFO", safeJsStringLiteral
(session_.pagePathInfo_));

bootJs.setCondition("COOKIE_CHECKS", conf.cookieChecks());
Expand Down Expand Up @@ -884,6 +888,7 @@ void WebRenderer::serveMainscript(WebResponse& response)
}
} else {
expectedAckId_ = scriptId_ = WRandom::get();
ackErrs_ = 0;
}

WApplication *app = session_.app();
Expand Down
2 changes: 1 addition & 1 deletion src/web/WebRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class WT_API WebRenderer : public Wt::SlotLearnerInterface
WebSession& session_;

bool visibleOnly_, rendered_, initialStyleRendered_;
int twoPhaseThreshold_, pageId_, expectedAckId_, scriptId_;
int twoPhaseThreshold_, pageId_, expectedAckId_, scriptId_, ackErrs_;
int linkedCssCount_;
std::string solution_;

Expand Down

0 comments on commit 95b2ad9

Please sign in to comment.