it doesn t have to be so hard efficient symbolic
play

It Doesnt Have to Be So Hard: Efficient Symbolic Reasoning for CRCs - PowerPoint PPT Presentation

It Doesnt Have to Be So Hard: Efficient Symbolic Reasoning for CRCs Vaibhav Sharma, Navid Emamdoost, Seonmo Kim, Stephen McCamant University of Minnesota, Minneapolis, MN, USA Motivation Cyclic Redundancy Check (CRC) is commonly used


  1. It Doesn’t Have to Be So Hard: Efficient Symbolic Reasoning for CRCs Vaibhav Sharma, Navid Emamdoost, Seonmo Kim, Stephen McCamant University of Minnesota, Minneapolis, MN, USA

  2. Motivation ● Cyclic Redundancy Check (CRC) is commonly used for error detection ● Not resistant to adversarial modification ○ WEP, SSHv1 ● Sometimes used as an obstacle to symbolic execution ○ Jung et al., USENIX Security 2019 ● Is analysis of CRC difficult?

  3. Our Contribution ● It is not difficult to analyze CRC implementations ● Use symbolic execution to compute pre-image of CRC ● Explore two kinds of CRC implementations ○ update CRC once for every input bit ○ update CRC using lookup table (for every 8 bits in input)

  4. Our Contribution ● It is not difficult to analyze CRC implementations ● Use symbolic execution to compute pre-image of CRC ● Explore two kinds of CRC implementations ○ update CRC once for every input bit ○ update CRC using lookup table (for every 8 bits in input)

  5. CRC symbolic pre-image computation int main() { char sym_str[LEN]; // set to symbolic bytes unsigned int sym_crc = crc(sym_str, LEN); char conc_str[LEN]; srand(time(NULL)); for ( int i = 0; i < LEN; i++) conc_str[i] = ( char ) rand(); if (sym_crc == crc(conc_str, LEN)) { printf("found the pre-image\n"); } return 0; }

  6. Our Contribution ● It is not difficult to analyze CRC implementations ● Use symbolic execution to compute pre-image of CRC ● Explore two kinds of CRC implementations ○ update CRC once for every input bit ○ update CRC using lookup table (for every 8 bits in input)

  7. Our Contribution ● It is not difficult to analyze CRC implementations ● Use symbolic execution to compute pre-image of CRC ● Explore two kinds of CRC implementations ○ update CRC once for every input bit ○ update CRC using lookup table (for every 8 bits in input)

  8. Our Contribution ● It is not difficult to analyze CRC implementations ● Use symbolic execution to compute pre-image of CRC ● Explore two kinds of CRC implementations Used by Jung et al. to ○ update CRC once for every input bit defeat symbolic execution ○ update CRC using lookup table (for every 8 bits in input)

  9. CRC Implementation Type #1 unsigned int fuzzification_crc32 ( unsigned char *message) { int i, j; unsigned int byte, crc; message points to i = 0; crc = 0xFFFFFFFF; symbolic bytes while (message[i] != 0) { byte = reverse(message[i]); for (j = 0; j <= 7; j++) { if (( int )(crc ^ byte) < 0) crc = (crc << 1) ^ 0x04C11DB7; else crc = crc << 1; byte = byte << 1; } i = i + 1; } return reverse(~crc); }

  10. CRC Implementation Type #1 unsigned int fuzzification_crc32 ( unsigned char *message) { int i, j; unsigned int byte, crc; i = 0; crc = 0xFFFFFFFF; while (message[i] != 0) { byte = reverse(message[i]); for (j = 0; j <= 7; j++) { if (( int )(crc ^ byte) < 0) crc = (crc << 1) ^ 0x04C11DB7; else crc = crc << 1; byte = byte << 1; } i = i + 1; } return reverse(~crc); }

  11. CRC Implementation Type #1 unsigned int fuzzification_crc32 ( unsigned char *message) { int i, j; unsigned int byte, crc; i = 0; crc = 0xFFFFFFFF; while (message[i] != 0) { byte = reverse(message[i]); for (j = 0; j <= 7; j++) { if (( int )(crc ^ byte) < 0) crc = (crc << 1) ^ 0x04C11DB7; else crc = crc << 1; byte = byte << 1; } i = i + 1; } return reverse(~crc); }

  12. CRC Implementation Type #1 unsigned int fuzzification_crc32 ( unsigned char *message) { int i, j; unsigned int byte, crc; i = 0; crc = 0xFFFFFFFF; while (message[i] != 0) { byte = reverse(message[i]); for (j = 0; j <= 7; j++) { if (( int )(crc ^ byte) < 0) crc = (crc << 1) ^ 0x04C11DB7; else crc = crc << 1; byte = byte << 1; } i = i + 1; } return reverse(~crc); }

  13. CRC Implementation Type #1 unsigned int fuzzification_crc32 ( unsigned char *message) { int i, j; unsigned int byte, crc; i = 0; crc = 0xFFFFFFFF; while (message[i] != 0) { byte = reverse(message[i]); for (j = 0; j <= 7; j++) { if (( int )(crc ^ byte) < 0) crc = (crc << 1) ^ 0x04C11DB7; else crc = crc << 1; byte = byte << 1; } i = i + 1; } return reverse(~crc); }

  14. CRC Implementation Type #1 unsigned int fuzzification_crc32 ( unsigned char *message) { int i, j; unsigned int byte, crc; i = 0; crc = 0xFFFFFFFF; while (message[i] != 0) { byte = reverse(message[i]); for (j = 0; j <= 7; j++) { if (( int )(crc ^ byte) < 0) crc = (crc << 1) ^ 0x04C11DB7; else crc = crc << 1; byte = byte << 1; } i = i + 1; } return reverse(~crc); }

  15. CRC Implementation Type #1 unsigned int fuzzification_crc32 ( unsigned char *message) { int i, j; unsigned int byte, crc; i = 0; crc = 0xFFFFFFFF; while (message[i] != 0) { ● Both sides of branch byte = reverse(message[i]); for (j = 0; j <= 7; j++) { feasible if (( int )(crc ^ byte) < 0) ● Executed once for every bit crc = (crc << 1) ^ 0x04C11DB7; in message else crc = crc << 1; byte = byte << 1; ● Causes path explosion } ● Can be easily alleviated i = i + 1; with path-merging } return reverse(~crc); }

  16. CRC Implementation Type #1 unsigned int fuzzification_crc32 ( unsigned char *message) { int i, j; unsigned int byte, crc; i = 0; crc = 0xFFFFFFFF; Summarize both sides of branch into while (message[i] != 0) { byte = reverse(message[i]); single formula for (j = 0; j <= 7; j++) { crc =( int )(crc ^ byte) < 0 if (( int )(crc ^ byte) < 0) ? (crc << 1) ^ 0x04C11DB7 crc = (crc << 1) ^ 0x04C11DB7; else crc = crc << 1; : crc << 1 byte = byte << 1; } i = i + 1; } return reverse(~crc); }

  17. CRC Implementation Type #1 unsigned int fuzzification_crc32 ( unsigned char *message) { int i, j; unsigned int byte, crc; i = 0; crc = 0xFFFFFFFF; ● Summarize both sides of branch while (message[i] != 0) { byte = reverse(message[i]); into single formula for (j = 0; j <= 7; j++) { ● Write side-effects of summary into if (( int )(crc ^ byte) < 0) local variable (crc) crc = (crc << 1) ^ 0x04C11DB7; else crc = crc << 1; ● Skip branching, jump to immediate byte = byte << 1; post-dominator of branch } instruction i = i + 1; } return reverse(~crc); }

  18. Our Contribution ● It is not difficult to analyze CRC implementations ● Use symbolic execution to compute pre-image of CRC ● Explore two kinds of CRC implementations ○ update CRC once for every input bit Used to make CRC ○ update CRC using lookup table (for every 8 bits in input) computation faster

  19. CRC Implementation Type #2 unsigned int cgc_crc32( char *buf, int len) { unsigned int c = 0xffffffff; int n; for (n = 0; n < len; n++) c = table[(c ^ buf[n]) & 0xff] ^ (c >> 8); return c ^ 0xffffffff; }

  20. CRC Implementation Type #2 unsigned int cgc_crc32( char *buf, int len) { unsigned int c = 0xffffffff; int n; buf points to for (n = 0; n < len; n++) symbolic bytes c = table[(c ^ buf[n]) & 0xff] ^ (c >> 8); return c ^ 0xffffffff; }

  21. CRC Implementation Type #2 unsigned int cgc_crc32( char *buf, int len) { unsigned int c = 0xffffffff; int n; for (n = 0; n < len; n++) c = table[(c ^ buf[n]) & 0xff] ^ (c >> 8); return c ^ 0xffffffff; }

  22. CRC Implementation Type #2 unsigned int cgc_crc32( char *buf, int len) { unsigned int c = 0xffffffff; int n; for (n = 0; n < len; n++) c = table[(c ^ buf[n]) & 0xff] ^ (c >> 8); return c ^ 0xffffffff; }

  23. CRC Implementation Type #2 unsigned int cgc_crc32( char *buf, int len) { unsigned int c = 0xffffffff; int n; for (n = 0; n < len; n++) c = table[(c ^ buf[n]) & 0xff] ^ (c >> 8); return c ^ 0xffffffff; }

  24. CRC Implementation Type #2 unsigned int cgc_crc32( char *buf, int len) { unsigned int c = 0xffffffff; ● Concrete table lookup with symbolic int n; index for (n = 0; n < len; n++) c = table[(c ^ buf[n]) & 0xff] a. Branch for every entry ^ (c >> 8); b. Read table contents into return c ^ 0xffffffff; If-Then-Else expression } c. Use theory of arrays d. Use the structure of the table to summarize its contents

  25. CRC Implementation Type #2 unsigned int cgc_crc32( char *buf, int len) { unsigned int c = 0xffffffff; ● Concrete table lookup with symbolic int n; index for (n = 0; n < len; n++) c = table[(c ^ buf[n]) & 0xff] a. Branch for every entry ^ (c >> 8); b. Read table contents into return c ^ 0xffffffff; If-Then-Else expression } c. Use theory of arrays d. Use the structure of the table to summarize its contents

  26. CRC Implementation Type #2 unsigned int cgc_crc32( char *buf, int len) { unsigned int c = 0xffffffff; ● Concrete table lookup with symbolic int n; index for (n = 0; n < len; n++) c = table[(c ^ buf[n]) & 0xff] a. Branch for every entry ^ (c >> 8); b. Read table contents into return c ^ 0xffffffff; If-Then-Else expression } c. Use theory of arrays d. Use the structure of the table to summarize its contents

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend