-
Can you explain your Perl Harbor exploit against Perl 1? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There is a race condition when a user passes Perl code with the command line 'e' option. Here's a plan that Perl 1 implements:
It would create a temporary file (e.g., /tmp/perl-emMuFDJ). That file is certain to contain the Perl code followed by a new line character. Then, the execution proceeds as if you execute:
The temporary file is deleted upon program termination. It should properly print the "hello, world" text. Let's take a closer look at the implementation in the perly.c file. I've inserted my code comments to make it easier to understand.
The two first points of the plan implemented are done by now. The Perl code is likely to reside in a buffer, and the temporary file is almost certain of size 0. The rest is done at the end of the switch().
Perl 1 interpreter will now proceed as if the temporary file was passed in a command-line argument. The moment just after it calls 'fclose()' is when the race conditions occur. It can be exploited by writing a possibly malicious code in the already created temporary file. In our example, it's /tmp/perl-emMuFDJ. to be vulnerable, an attacker must have write access to that temporary file. There are several cases when it can be done:
Here's a plan implemented:
Exploitation is successful when Perl 1 doesn't manage to execute its code before it gets swapped with the infected one. It can be unsuccessful if Perl Harbor swaps the file too early or too late. Thus, there are three possible endings:
You can get the complete exploit in C programming language from GitHub. |
Beta Was this translation helpful? Give feedback.
There is a race condition when a user passes Perl code with the command line 'e' option. Here's a plan that Perl 1 implements:
Suppose you want to print a 'hello, world' text with Perl 1.
It would create a temporary file (e.g., /tmp/perl-emMuFDJ). That file is certain to contain the Perl code followed by a new line character. Then, the execution proceeds as if you execute: