- There are types of vulnerabilities at the system level:
authentication, malware, memory management, and file system
vulnerabilities.
- There are 2 main issues with memory security: Preventing
someone from reading from RAM they shouldn't, and preventing
someone from writing to RAM they shouldn't.
- We already know how reading protection is done: in hardware.
Each memory access is compared to a bounds pointer before being
allowed to go to memory. If a reference exceeds the bounds
pointer, generate an exception.
- But what about shared memory?
- One process makes the request, we allocate a page for the memory.
- The process has a virtual address that corresponds to the page.
- Another process attaches to the shared memory, receives
a different virtual address that corresponds to the
same physical address in the page table.
- In POSIX, permissions are handled just like file
permissions, so as long as authentication is assured, we're
pretty good. See ipcs -m
- Write to memory. See demo.
- Usually the point is not to modify the data like that, but to
overwrite the pointer
- We need to know something about the layout of the program to
be effective. This is easy for open source, harder for closed, but
not that much harder...
- See demo... disas main, info registers
- Another thing a bad guy can do is insert code into the stack,
and if he can get the old fram pointer to point to that
code, then it can run arbitrary code. Disco.
- So what can we do about this:
- Program-time defenses
- Don't use C. Seriously, use something with modern
memory protections.
- Don't program stupidly. Don't use gets(), use
fgets(). Or get individual characters. Or don't use C.
- Compile and link time
- Have compiler insert bounds checks automatically.
Works for staticly allocated arrays, but can't be done for
dynamic.
- Use fancy safe extensions
like libsafe.
- Compiler generates code that examines the stack frame
for evidence of corruption.
- Stackguard compiler extension writes a canary
value before and after the the old frame pointer, and
checks to see if it is modified before returning.
- Run time
- Why not tag some pages as executable, and all others
are not. Requires hardware support.
- Randomize addresses. System calls?