Symbolic memory addressing #95
-
Hello, I'm trying to experiment with how Maat handles symbolic memory addressing. I have the following C program, which contains an input-indexed load and a potential crash:
Which emits the following assembly:
If I create an engine, set cpu.rax to a symbolic value, then execute run_from(0x1181, 1), the resulting rax is a large expression of ITEs - I'm trying to then evaluate the range of possible indices and thereby loaded values, using the solver, but I cannot seem to figure out the minimum and maximum possibilities. Would you happen to have any advise and/or any guidance on handling symbolic memory addressing in general? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
We are planning to write a tutorial that focuses on symbolic memory specifically, but until then I can try to provide some insights :) First of all, I will point out that if
The ITE expression returned technically does this for you. Maat returns a conditional expression containing all possible loaded values depending on the memory index. Now, I assume that what you want to do is extract and isolate the list of possible indexes, perhaps to check if they can be out of bounds? It is not possible to extract them from the ITE expression directly. However, when handling symbolic pointers, Maat internally computes the range of possible values that the pointer can take as a value set which consists in a minimum value, a maximum value, and a stride. For instance a value set of
There's actually already a dedicated issue for this: #18 Important note: the value set for symbolic pointers will vary depending on whether the Important note 2: there are other options that tweak symbolic memory behaviour, such as restraining the range of possible values for pointers to a hardcoded maximal size, etc. Take a look at the Settings class for more. |
Beta Was this translation helpful? Give feedback.
-
Really? I didn't realize that - does it not do it by default? I would
think that would be preferred over doing the range/VSA. I may have to test
a little more and see if I could produce a counterexample.
…On Fri, May 13, 2022 at 1:00 PM Boyan MILANOV ***@***.***> wrote:
Actually Maat already uses a memory model very close to MemSight, with
only two differences:
- no support for state merging
- with concolic data, instead of introducing new symbols for potential
accesses to uninitialised memory, Maat uses the concrete value of the
symbolic expression as the default address
Did you observe some symbolic memory behaviour that doesn't match what you
expected to see?
To be honest I think Mayhem was describing a very similar approach to
MemSight in their CGC paper, from which we took some ideas to implement
symbolic memory in Maat.
—
Reply to this email directly, view it on GitHub
<#95 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACRPRYR5XCNAEHHRKHSTJWLVJ2DCTANCNFSM5VYTJKOQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I'm happy to share more examples as I go after them. I'm starting with the
simple one I posted above, and after that I'll probably try something like
CGC binaries since they're a bit more complex.
I looked more at the white paper and the algorithm - you mention above they
"build ITEs" for reads to memory, but looking at the algorithm, I'm not
sure it's the same thing - the ITE in that load algorithm seems to be for
checking the list of addr/value tuples that are maintained in the state,
and then returning a value of one of the addresses match the requested one
(again, the addresses in this case being symbolic). Are these tuples
maintained in maat's state model? I think this works fundamentally
differently from the ITE resulting from the VSA method you mention - which
is the same as (or similar to) the way angr does it.
Does that make sense? Or am I still missing something?
…On Fri, May 13, 2022 at 3:36 PM Boyan MILANOV ***@***.***> wrote:
Yeah. I'd be interested in the examples you're trying to solve if you
don't mind sharing them. More experimenting with symbolic memory is always
welcome, and I would certainly be able to provide some insights on
potential tweaks of Maat's symbolic memory settings to make the examples
work :)
—
Reply to this email directly, view it on GitHub
<#95 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACRPRYWV67ZYAV3TIAMHUO3VJ2VKLANCNFSM5VYTJKOQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
We are planning to write a tutorial that focuses on symbolic memory specifically, but until then I can try to provide some insights :)
First of all, I will point out that if
rax
is symbolic and can have any value, then the expressionrbp+rax*1-0xa
can also take pretty much any value from0x0
to0xffffffffffffffff
.The ITE expression returned technically does this for you. Maat returns a conditional expression containing all possible loaded values depending on the memory index.
Now, I assume that what you want to do is extract and isolate the list of possible indexes, perhaps to check if they can be out o…