Skip to content

Symex taint analysis #247

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

Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions regression/symex-taint-analysis/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
default: tests.log

test:
@../test.pl -c ../../../src/symex/symex

tests.log: ../test.pl
@../test.pl -c ../../../src/symex/symex

show:
@for dir in *; do \
if [ -d "$$dir" ]; then \
vim -o "$$dir/*.c" "$$dir/*.out"; \
fi; \
done;
15 changes: 15 additions & 0 deletions regression/symex-taint-analysis/array-all-taint-inline/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <assert.h>

int main(){

int x[4];

int y = x[0];

int c = ++y;

// assert c is tainted.
assert(__CPROVER_is_taint("main::1::c", "tainted"));

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"loc": 0,
"taint": "tainted"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple --taint-file taint.json
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
15 changes: 15 additions & 0 deletions regression/symex-taint-analysis/array-all-taint-json/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <assert.h>

int main(){

int x[4];

int y = x[0];

int c = ++y;

// assert c is tainted.
assert(__CPROVER_is_taint("main::1::c", "tainted"));

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"loc": 0,
"taint": "tainted"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple --taint-file taint.json
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
17 changes: 17 additions & 0 deletions regression/symex-taint-analysis/array-taint-inline/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <assert.h>

int main(){

int x[4];

__CPROVER_set_taint("main::1::x[3]", "tainted");

int y = x[3];

x[0] = ++y;

// assert c is tainted.
assert(__CPROVER_is_taint("main::1::x[0]", "tainted"));

return 0;
}
8 changes: 8 additions & 0 deletions regression/symex-taint-analysis/array-taint-inline/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
15 changes: 15 additions & 0 deletions regression/symex-taint-analysis/array-taint-json/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <assert.h>

int main(){

int x[4];

int y = x[3];

x[0] = ++y;

// assert c is tainted.
assert(__CPROVER_is_taint("main::1::x[0]", "tainted"));

return 0;
}
7 changes: 7 additions & 0 deletions regression/symex-taint-analysis/array-taint-json/taint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"loc": 0,
"taint": "tainted",
"symbol": "main::1::x[3]"
}
]
8 changes: 8 additions & 0 deletions regression/symex-taint-analysis/array-taint-json/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple --taint-file taint.json
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
17 changes: 17 additions & 0 deletions regression/symex-taint-analysis/array-untaint-inline/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <assert.h>

int main(){

int x[4];

__CPROVER_set_taint("main::1::x[3]", "tainted");

int y = x[3];

x[1] = ++y;

// assert c is tainted.
assert(!__CPROVER_is_taint("main::1::x[0]", "tainted"));

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
18 changes: 18 additions & 0 deletions regression/symex-taint-analysis/func-taint-inline/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <assert.h>
#include <stdlib.h>

int main(){

int *x = malloc(sizeof(int));

__CPROVER_set_taint("main::1::x", "tainted");

*x = 9;

int *y = x;

assert(__CPROVER_is_taint("main::1::y", "tainted"));
free(y);

return 0;
}
8 changes: 8 additions & 0 deletions regression/symex-taint-analysis/func-taint-inline/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
27 changes: 27 additions & 0 deletions regression/symex-taint-analysis/loop-taint-inline/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <assert.h>

int main() {

int j;

__CPROVER_set_taint("main::1::j", "tainted");

int x[4];

int i = 0;

for (i = 0; i < 4; i++) {

if (i == 3)
x[i] = j;
else
x[i] = 0;
}

assert(__CPROVER_is_taint("main::1::x[0]", "untainted"));
assert(__CPROVER_is_taint("main::1::x[1]", "untainted"));
assert(__CPROVER_is_taint("main::1::x[2]", "untainted"));
assert(__CPROVER_is_taint("main::1::x[3]", "tainted"));

return 0;
}
8 changes: 8 additions & 0 deletions regression/symex-taint-analysis/loop-taint-inline/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
24 changes: 24 additions & 0 deletions regression/symex-taint-analysis/loop-untaint-inline/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <assert.h>

int main(){

int j;

__CPROVER_set_taint("main::1::j", "tainted");


int x[4];

int i = 0;

for (i = 0; i < 4; i++){

x[i] = (i == 8) ? j : 0;
}


assert(__CPROVER_is_taint("main::1::x[3]", "tainted"));


return 0;
}
8 changes: 8 additions & 0 deletions regression/symex-taint-analysis/loop-untaint-inline/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
22 changes: 22 additions & 0 deletions regression/symex-taint-analysis/pointer-taint-inline/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <assert.h>

int main(){

int y;

__CPROVER_set_taint("main::1::y", "tainted");

int *x = &y;

int *c = x;

int z = *x;

assert(__CPROVER_is_taint("main::1::y", "tainted"));
assert(__CPROVER_is_taint("main::1::z", "tainted"));
assert(__CPROVER_is_taint("main::1::x", "untainted"));
assert(__CPROVER_is_taint("main::1::c", "untainted"));


return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
24 changes: 24 additions & 0 deletions regression/symex-taint-analysis/pointer-untaint-inline/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <assert.h>

int main(){

int y;

__CPROVER_set_taint("main::1::y", "tainted");

int *x = &y;

int *c = x;

*c = 0;
int z = *x;


assert(__CPROVER_is_taint("main::1::y", "untainted"));
assert(__CPROVER_is_taint("main::1::z", "untainted"));
assert(__CPROVER_is_taint("main::1::x", "untainted"));
assert(__CPROVER_is_taint("main::1::c", "untainted"));


return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
22 changes: 22 additions & 0 deletions regression/symex-taint-analysis/recursive-taint-inline/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <assert.h>

int factorial(unsigned int i) {

if (i <= 1) {
return 1;
}
return i * factorial(i - 1);
}

int main() {

unsigned int x = 80;

__CPROVER_set_taint("main::1::x", "tainted");

unsigned int y = factorial(x);

assert(__CPROVER_is_taint("main::1::y", "tainted"));

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--taint simple
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
26 changes: 26 additions & 0 deletions regression/symex-taint-analysis/recursive-untaint-inline/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <assert.h>

int factorial(unsigned int i) {

if (i <= 1) {
return 1;
}
return i * factorial(i - 1);
}

int main() {

unsigned int y;

unsigned int x = 80;

__CPROVER_set_taint("main::1::x", "tainted");

y = factorial(x);

y = 0;

assert(!__CPROVER_is_taint("main::1::y", "tainted"));

return 0;
}
Loading