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

Simple DoS on bblfhsd with error re-scaling pool: context canceled #253

Closed
bzz opened this issue Feb 22, 2019 · 0 comments · Fixed by #254
Closed

Simple DoS on bblfhsd with error re-scaling pool: context canceled #253

bzz opened this issue Feb 22, 2019 · 0 comments · Fixed by #254
Assignees
Labels

Comments

@bzz
Copy link
Contributor

bzz commented Feb 22, 2019

Parsing this syntactically incorrect js fragment triggers https://github.com/bblfsh/sdk/issues/371 but if a bblfshd is used instead of the driver directly - this condition kick the bblfhsd v2.11.7 into the infinite loop on the next request to the same driver

Logs

time="2019-02-21T21:11:10Z" level=error msg="error re-scaling pool: context canceled" language=javascript
time="2019-02-21T21:11:10Z" level=debug msg="scaling driver pool from 0 instance(s) to 1 instance(s)" language=javascript
time="2019-02-21T21:11:10Z" level=debug msg="spawning driver instance "bblfsh/javascript-driver:latest" ..."
time="2019-02-21T21:11:10Z" level=error msg="error re-scaling pool: context canceled" language=javascript
time="2019-02-21T21:11:10Z" level=debug msg="scaling driver pool from 0 instance(s) to 1 instance(s)" language=javascript
time="2019-02-21T21:11:10Z" level=debug msg="spawning driver instance "bblfsh/javascript-driver:latest" ..."

Could be related to #252

Steps to reproduce

Same as in https://github.com/bblfsh/sdk/issues/371 but with bblfshd instead of only the driver.

@bzz bzz added the bug label Feb 22, 2019
@dennwc dennwc self-assigned this Feb 22, 2019
dennwc pushed a commit to dennwc/bblfshd that referenced this issue Feb 22, 2019
Signed-off-by: Denys Smirnov <denys@sourced.tech>
dennwc pushed a commit to dennwc/bblfshd that referenced this issue Feb 22, 2019
Previous changes added a context argument to newDriverPool, which is
called when the first request for the driver is received. By mistake,
the context of this first request is captured by the closure and is used
to create all other driver instances. Thus, if the first request
specifies the context timeout and fails for some reason, all future
requests will fails with "context cancelled" error.

Instead, we need to pass the real context from the user request down to
the pool's driver factory function.

This is not an ideal way of managing drivers - pool should be managed by
a separate goroutine. This will be implemented later. This is merely a
hotfix for the real issue.

Signed-off-by: Denys Smirnov <denys@sourced.tech>
dennwc pushed a commit that referenced this issue Feb 22, 2019
Previous changes added a context argument to newDriverPool, which is
called when the first request for the driver is received. By mistake,
the context of this first request is captured by the closure and is used
to create all other driver instances. Thus, if the first request
specifies the context timeout and fails for some reason, all future
requests will fails with "context cancelled" error.

Instead, we need to pass the real context from the user request down to
the pool's driver factory function.

This is not an ideal way of managing drivers - pool should be managed by
a separate goroutine. This will be implemented later. This is merely a
hotfix for the real issue.

Signed-off-by: Denys Smirnov <denys@sourced.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants