-
Notifications
You must be signed in to change notification settings - Fork 215
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
Decorator UniqueSize
doesn't yield unique results
#152
Comments
@defparam any ideas? |
I'll take a peek today, there is critical path through the decorator implementation that likely isn't thread safe causing these race conditions. I've noticed it too and have been meaning to fix it. |
As I suspected, adding a global lock in the decorator fixes this issue. The issue comes when responses are collected on burst back when starting a test. Each thread competes to get to handleResponse and the decorator attempts to deal with each response one at the time. However in reality atomicity is not promised and I should have added a threading lock to each of these implementations. I don't have a pull request yet because I need more time to test the fix for each of the decorators but here is the fix for Best, import threading
decoratorLock = threading.Lock()
def UniqueSize(instances=1):
def decorator(func):
def handleResponse(req, interesting):
global CodeLength
decoratorLock.acquire()
try:
CodeLength
except:
CodeLength = {}
if "lastreq" in CodeLength:
currreqs = req.engine.engine.successfulRequests.intValue()
lastreqs = CodeLength["lastreq"]
if currreqs < lastreqs:
CodeLength = {}
CodeLength["lastreq"] = currreqs
CodeLength["lastreq"] = req.engine.engine.successfulRequests.intValue()
codelen = str(req.status) + str(req.length)
if codelen in CodeLength:
if CodeLength[codelen] >= instances:
decoratorLock.release()
return
else:
CodeLength[codelen] += 1
else:
CodeLength[codelen] = 1
decoratorLock.release()
func(req, interesting)
return handleResponse
return decorator |
I tested your patch and it works fine. Well done! 👍 |
Tested version: v1.5 as a Burp extension
The documentation states that
@UniqueSize
should return one instance of responses with a given status/size. I tested it on a few endpoints and always got extra entries (even on a static image).The script
The base request:
The results:
This bug isn't new and I noticed it before but totally forgot to create an issue.
The text was updated successfully, but these errors were encountered: