Chapter 18 improving security with patches
the unauthorized reproduction in whole or in part of this publication in any form is prohibited
in this lesson we will get to know the core and compiler patches that improve the level of system security.
Let's copy the necessary files onto the computer hard disk.
We will start by unpacking the core sources and putting the security patch ph X in place.
To install the patch we will use the patch command.
We can therefore proceed with the most important task.
The configuration of the P.A. X system
to make the task slightly simpler we will upload the alternative G.R. security configuration file.
We can finally proceed with the patch configuration a description of all available options is included
in the handbook
after terminating the configuration we save our settings and leave the configurator.
The next step is the compilation of the new core and all modules.
We will therefore perform a series of make commands.
After a couple of minutes depending on the hardware resources of the computer the new kernel is ready
for installation.
Let's make the appropriate entry in the lilo configuration file to make the new kernel visible during
the start
after reloading the boot manager.
We have to restart the system using the reboot command.
After the new startup of the computer.
It's time to test the functioning of the patch.
We will use the pack's test tool set for this purpose
as we can see by using G.R. security.
The majority of attacks has been detected.
Now let's look at another patch.
It's time for the gcc compiler.
We will now unpack the compiler sources that we copied earlier and install the stack smashing protector
patch
we have now to configure and compile GCC a new version of the compiler will be available in the U.S.
are slash Peepy directory.
After compiling it's time to install the new compiler in the system.
Now we will test stack smashing protector on an example.
As we can see after compiling the program using the old version of gcc it was possible to overwrite
the stack frame.
Let's now check how our program will behave after compiling with the modified gcc version.
As we can see the attack attempt has been noted in the program and has been terminated before the stack
frame could be overwritten.
By default the patch secures only the character table's.
Let's check this on our next example.
To make possible the protection of other types of data as well we must use the stack protector all option
during compilation
as we can see the attack to temp has been detected to check how stack smashing protector works we will
analyze our program with gdb
control a variable.
Overwriting is possible thanks to the application of guards.
We can certain this by following the program execution step by step
in the case of normal program performance.
The guard variable is not overwritten
after an argument that is too long has been transferred.
The guard variable is overwritten and the comparison occurring in the program body indicates the occurrence
of the attack.
Now let's look at the safe library.
It is a safe equivalent of the standard IBC library
as we can see the next example uses the dangerous gets function which is also signaled by the compiler
to add the IB safe library to each program being started it is necessary to modify the L.D. underscore
pre-load system variable
as we can see.
Our program ended without errors despite using the dangerous gets function.