Skip to content

JavaSecurityFeatures

Razvan Deaconescu edited this page Jun 3, 2019 · 5 revisions

Java Security Features

Java is a modern programming language that was designed with security in mind. As such, Java remove many of the potential flaws that plague lower-level languages such as C or C++. Still, Java programs may still have defects that are exploitable.

In this chapter we inspect features of the Java programming languages, particularly those dealing with security. We show how Java compares to C and C++, with added security as an advantage but a reduced running time as a disadvantage.

Concepts

a program during runtime (a process): CPU, memory, I/O, IPC

a program consists of data and code: CPU instructions

from source code to a process: compiler, linker, loader

bytecode, virtual machines, overhead

the Java Virtual Machine (JVM), portability

compiler enhancements, runtime enhancements

memory safety: no buffer overflows, no out of bounds data

Java summary: classes, members, methods, private/public/protected, constructors, garbage collectors, final, static, data types, objects, subclasses, inheritence

packages in Java

compiling programs, the classpath, running programs in JVM, .class files

Tasks

Espresso

Enter the 02-java-security-features/espresso/ subfolder in the repository. There is .class file that you can decompile and extract the original Java code. Analyze that code and get the flag (i.e. the string that gives you the correct message).

Based on: Codemash 2019 Espresso

Use this Java decompiler.

Private

Enter the 02-java-security-features/private/ subfolder in the repository. Check the source code files. Then use make to compile all programs. Test then and see what is the outcome of using the private and public keyword.

Memory Safety

Enter the 02-java-security-features/mem-safety/ subfolder in the repository. Check the source code files. Then use make to compile all programs. Test then and see what is the effect of accessing a buffer outside its bounds. Compare Java to C/C++.

strcpy

Enter the 02-java-security-features/strcpy/ subfolder in the repository. Check the source code files. Then use make to compile all programs. See different methods of doing string copies and how the C variant of using strings can be abused.

Use Python to provide a lenghty argument, such as

./strcpy_cpp "$(python -c 'print "C"*1000')"

Security Manager

Enter the 02-java-security-features/security-manager/ subfolder in the repository. Check the source code file. Find the issue with it, exploit the issue and then fix it to prevent it from happening again.

Based on: SEC04

Documentation on Java policy files is here.

Clone this wiki locally