-
Notifications
You must be signed in to change notification settings - Fork 103
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
Fix issues when running JS challenge #1395
Conversation
…e to template unavailability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes do make sense and looks good except #1203 degradation.
…uest header First browser request always contains `text/html` token since it tries to load DOM. Even if it tries to load image. But in the same time `*/*` is forwarded in almost all browser request, thus every image, favicon and other requests are treated by Tempesta as requests allowed to run JS code. That's not true and this requests violate JS challenge conditions.
Give an empty file as favicon image, so browser never sends a `/favicon.ico`. This reduce requests during JS challenge processing from two to one. The code was borrowed from https://stackoverflow.com/questions/1321878/how-to-prevent-favicon-ico-requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the small code improvements
tempesta_fw/http_parser.c
Outdated
TRY_STR("html", Req_I_AfterTextSlash, Req_I_AcceptHtml); | ||
if (c == '*') | ||
__FSM_I_MOVE(I_EoT); | ||
__FSM_I_JMP(Req_I_AfterTextSlashToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just fall through
tempesta_fw/http_parser.c
Outdated
@@ -5294,27 +5298,29 @@ __h2_req_parse_accept(TfwHttpReq *req, unsigned char *data, size_t len, | |||
} | |||
|
|||
__FSM_STATE(Req_I_AfterTextSlash) { | |||
if (c == '*') | |||
__FSM_H2_I_MOVE(I_EoT); | |||
__FSM_I_JMP(Req_I_AfterTextSlashToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same - just fall through, no need to jump
Fix #1393
Changes:
*/*
token inAccept:
header as allowing to send JS challengefavicon.ico
request. Empty favicon is integrated into JS challenge template.