Secure application development with AOP
Nils Durner
<ndurner@web.de> 1
Secure application development with AOP Nils Durner - - PowerPoint PPT Presentation
Secure application development with AOP Nils Durner <ndurner@web.de> 1 Outline of the talk Introduction to Aspect Oriented Programming Examples for uses of AOP for security AOP & Memory safety Future work 2 What is
<ndurner@web.de> 1
2
3
4
5
1AspeCt-oriented C: global variables only 2AspectC ++ 6
int glob; int foo(int i) { // before function return glob += i; // variable get and set // after function } int main () { int i; glob = 5; // variable set i = 2; foo(i); // function call printf("glob: %u\n", glob); // variable get & function call return 0; }
7
8
9
10
#include <stdio.h> void *around(size_t size): (call($ malloc (...))) && args(size) { void *ptr; if (size > 100000000) { fprintf(stderr , "FATAL: unexpected large allocation in %s::%s()", this ->fileName , this ->targetName); return NULL; } if (! (ptr = proceed ())) { fprintf(stderr , "FATAL: cannot allocate %u bytes in %s::%s()", size , this ->fileName , this ->targetName); } return ptr; }
11
public class ApplicationDetailsServlet extends HttpServlet { protected void doGet( HttpServletRequest req , HttpServletResponse resp) { private static final Logger logger = Logger.getLogger( ApplicationDetailsServlet .class.getName ()); if (! (req.isUserInRole("recruiter") || req.isUserInRole("head of unit"))) { logger.error("Unauthorized access to application details by user " + req.getRemoteUser ()); resp.sendError( HttpServletResponse .SC_UNAUTHORIZED ); return; } logger.info("access to application " + req.getParameter("id")); // functional code }
12
13
14
15
tacc hello.c hello.acc -o hello
16
17
18
void __attribute__ (( constructor)) init_rand () { gcry_check_version (NULL); } int around (): call(int rand ()) { int ret; gcry_randomize (( unsigned char *) &ret , sizeof (int), GCRY_STRONG_RANDOM ); return ret; }
19
20
21
22
struct { char *filename; } include; introduce (): intype(struct include) { int trusted; }
23
24
25
26
27
SIZE_T WINAPI VirtualQuery( __in_opt LPCVOID lpAddress , __out PMEMORY_BASIC_INFORMATION lpBuffer , __in SIZE_T dwLength );
28
$ cat /proc/self/maps 08048000 -0804 c000 r-xp 00000000 03:01 13496 /bin/cat 0804 c000 -0804 d000 rw -p 00004000 03:01 13496 /bin/cat 0804 d000 -0806 e000 rw -p 0804 d000 00:00 0 [heap] ...
29
30
31
3see also http://cvs.savannah.gnu.org/viewvc/*checkout*/guile/guile-core/libguile/threads.c?
32
33
34
35
4on x86 36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59