-
Notifications
You must be signed in to change notification settings - Fork 210
Very high security flaws found in PCRE: use memcpy_s if available #207
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
Comments
not sure about the other entries, but at least src/pcre2_match.c:7498 corresponds to:
which can't be neither CWE ID 121 nor CWE ID 190 as it copies data to a newly created pointer in the HEAP. could there be a mistake in the report? |
All except one of the others are similar: complaining about a memcpy() into a newly allocated heap block. The odd one out is line 4008 in pcre2_match.c which is:
which is just one example of many similar lines with different ctype_xxxx masks - so why only the one complaint? Anyway I can't see anything wrong with any of these. |
Tks gentlemen.
so perhaps that screwed line numbers ? The line number 7498 is: Line 7498 in 52c0884
and the CWE ID 121 https://cwe.mitre.org/data/definitions/121.html so perhaps veracode indeed is reporting the bad CWE ID or simply means 'overflow'. Seen on their website: https://community.veracode.com/s/question/0D53n00007qVSblCAG/stackbased-buffer-overflow-cwe-id-1212-flaws-in-cc perhaps they just advice to use memcpy_s ? https://en.cppreference.com/w/c/string/byte/memcpy |
memcpy_s is defined in an optional Appendix to C11 but I don't seem to have it on my Arch Linux box, which has both gcc and clang installed. I therefore suspect it isn't widely available. |
hum indeed, memcpy_s hard to find: |
Blindly replacing memcpy with memcpy_s doesn't seem like a productive change, specially since it might be not what the tool was originally suggesting (unless more than a hunch could be used to validate that, and considering the conflicting and unusual reports). |
I did a dummy test and veracode seems happy with memcpy_s. |
its removal from the standard has been also proposed: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1967.htm more importantly; except for a theoretical and unlikely scenario it doesn't seem to add any value. does the following patch (as an alternative to moving to memcpy_s from memcpy) also resolve the alert in
|
I agree with upstairs. In fact, memcpy_s ensures that the copy length does not overflow. This problem can be avoided as long as we ensure that the length of memcpy does not overflow. The memcpy_s solution is not the only one. |
I am closing this issue as it is clear that using memcpy_s() is not something that is going to happen in PCRE2. |
Hi
veracode analysis
https://www.veracode.com/products/binary-static-analysis-sast
has identified 5 "very high security flaws" in the latest release (10.42):
3 Stack-based Buffer Overflow (CWE ID 121) in:
and
2 "numeric errors" Integer Overflow or Wraparound (CWE ID 190)
ref:
https://cwe.mitre.org/
Would you consider investigating it ?
best
The text was updated successfully, but these errors were encountered: