-
Notifications
You must be signed in to change notification settings - Fork 900
Validate asn date based on position of Z #8603
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
base: master
Are you sure you want to change the base?
Conversation
|
jenkins retest this please |
|
Jenkins retest this please |
|
jenkins retest this please |
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.
Needs a test case
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.
Needs a test case
|
It will always eventually succeed. Need to redesign this part so we actually record whether it was generalized or utc. |
|
Please do not merge. I would like to squash this once it is approved. |
|
Jenkins retest this please |
| * built into macro values. */ | ||
| if (format == ASN_UTC_TIME) { | ||
| /* UTCTime format requires YYMMDDHHMMSSZ. */ | ||
| if (date[i + ASN_UTC_TIME_SIZE - 2] != 'Z') { |
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.
I don't see any guard to prevent an out-of-bounds read here, which would result in undefined behavior.
GetTimeString() is passed a len arg, but does not pass it on to ExtractDate(), and does not do any bounds checking of its own before passing date to ExtractDate().
Note that the unsafe logic can be reached from public API wolfSSL_ASN1_TIME_to_string(), also with no relevant bounds protection, so this is really not OK on that basis alone.
Bottom line, a refactor is needed to pass the len to ExtractDate() and use it for bounds checking.
Also note that the existing calls in ExtractDate() to btoi() and GetTime() are unsafe if date is not null-terminated. It is never safe to handle a non-null-terminated string without having and honoring an explicit length, but worse, there is no way to use btoi() and GetTime() safely on non-null-terminated strings.
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.
@douzzer ,
Not sure how we can resolve this. Note the following:
int wc_ValidateDate(const byte* date, byte format, int dateType)
...
if (!ExtractDate(date, format, &certTime, &i)) {
WOLFSSL_MSG("Error extracting the date");
return 0;
}
No len is passed in to wc_ValidateDate(). It is a wolfcrypt local function, but it is macrofied to XVALIDATE_DATE . I think in order to get the level of safety you are looking for we need a major refactor which would fall way out of the scope of this PR.
I suggest your proposal be done in another PR. Let me know your thoughts.
Fixes #8597