Rules: Complete support for lengths beyond 128#5891
Rules: Complete support for lengths beyond 128#5891solardiz merged 4 commits intoopenwall:bleeding-jumbofrom
Conversation
|
Actually, the +++ b/src/rules.c
@@ -201,16 +201,11 @@ static char *conv_tolower, *conv_toupper;
#define VALUE(value) { \
if (!((value) = RULE)) goto out_ERROR_END; \
}
-/* The pos variable may be signed or unsigned int, which affects comparison */
#define POSITION(pos) { \
- if (((pos) = rules_vars[ARCH_INDEX(RULE)]) > INFINITE_LENGTH) { \
- if (pos > (unsigned int)-MAX_PLAINTEXT_LENGTH) \
- pos = INFINITE_LENGTH; \
- else \
- goto out_ERROR_POSITION; \
- } \
+ if (((pos) = rules_vars[ARCH_INDEX(RULE)]) == INVALID_LENGTH) \
+ goto out_ERROR_POSITION; \
}
#define CLASS_export_pos(start, true, false) { \
char value, *class; \
@@ -1239,9 +1234,10 @@ char *rules_apply(char *word_in, char *rule, int split)
case 'T':
{
unsigned int pos;
POSITION(pos)
- in[pos] = conv_invert[ARCH_INDEX(in[pos])];
+ if (pos < length)
+ in[pos] = conv_invert[ARCH_INDEX(in[pos])];
}
break;
case 'D':However, then we need to worry about possible integer overflows in calculations in a few other command implementations. We could avoid those by making the Any thoughts? |
I've just reworked this PR to implement proper range checking for each command where this was missing or incomplete. |
|
@AlekseyCherepanov We could use some fuzzing of the rules engine - mangled rules based on our existing rulesets (before or after preprocessor expansion), maybe invoking |
magnumripper
left a comment
There was a problem hiding this comment.
Looks fine. I'll actually check this out and run some tests as well.
|
Thank you @magnumripper. My testing so far included running a tiny wordlist consisting of long lines around 128, 256, and 320 chars with our |
magnumripper
left a comment
There was a problem hiding this comment.
Ran out of time, I did few tests with very long input (which is what's most important, but I had no time to create a good wordlist for that - just many repeated characters is not good enough)
But I did test it with all sorts of obscure rules not in our repo.
…ut@v5" This reverts commit 5d9397e.
in an attempt to avoid the Ubuntu 24.04 ASan AVX-512 false positives. Fixes openwall#5875 hopefully this time for real
|
I've just inserted commit Rules: Move RULE_WORD_SIZE from params.h to rules.c. |
See #5873