Closed erhlee-bird closed 1 year ago
Thanks for the detailed report! I'll have to take a deeper look at this.
And instruction
scope or feature (https://github.com/mandiant/capa/issues/767) would help for sure with various FPs.
Just a contextual comment: One of the issues I encountered when writing this signature is just the sheer amount of variations encountered of this algorithm. Fortunately, most implementations have the same features (Digit summing, lookup tables).
I roughly documented variants of the algorithm that this rule was written against -> https://github.com/re-fox/documentation/blob/master/algorithms/luhns.md. While I don't think all of those are in capa-testfiles
, they may help give some samples to regression test against.
With this said, adding the instruction
scope would help in reducing FP's, especially when dealing with samples where the basic blocks contain a lot of arithmetic or are overly large.
We've since added the instruction scope and improved the rule accordingly.
2., 3. and 4. now do not hit anymore, so the function should not and does not match :)
Summary
Rule Name: "validate payment card number using luhn algorithm with no lookup table"
The aforementioned rule doesn't match against a version of notepad.exe (sha256:d66458a3eb1b68715b552b3af32a9d2e889bbf8ac0c23c1afa8d0982023d1ce2).
I don't think the file is actually exhibiting the represented behavior but the rule seems like it should match from how the rule is written.
Examples
notepad.exe (sha256:d66458a3eb1b68715b552b3af32a9d2e889bbf8ac0c23c1afa8d0982023d1ce2) Function located at 14000a098
Possible improvements
As a false negative, I think the rule should match according to the specified rule features.
So if this rule did match, I think it would actually be a false positive as a result of the basic block scope being very wide.
If the "Final section returning checkum % 10" rule were at like an instruction scope to look for specifically
div 10
or something along those lines, this probably wouldn't match.Additional context