Some time ago we got the idea to select projects alphabetically, pick a project for each letter from a to z and find at least one bug in it.
We don’t have a strict plan, rules or deadlines. We treat it is a freestyle battle and we just test whatever we want to.
Our goal is to try different approaches including many flavours of fuzzing, code review, static analysis, dynamic
analysis, divination etc. We’re going to write not only about what worked for us, but also about our failures. We plan
to issue posts on each letter randomly, so here’s the first post for the letter A!
A is for Alpine.
Alpine is a terminal e-mail client which was created
at the University of Washington as a Pine rewrite. The truth behind this choice is that our friend is a hard-core
alpine user, while some of us are in the mutt camp. So we thought that it would be fun to crash his favourite
We tried to take a simpliest possible approach to cause crashes and detect them.
To generate test cases we decided to use the greatest mutator available - Radamsa.
It is just a binary, so we created a simple python wrapper:
As Alpine has many options, we chose a few ones which seemed to have the greatest potential:
Detection was based on AddressSanitizer (ASan) - memory error detector, which have to enabled during compilation:
ASan also required runtime configuration, to save crashes with names allowing to track corresponding test case and its payload to repeat a crash.
The last step was to run Alpine from the script. It wasn’t so easy as just executing a binary with generated options, because Alpine runs in an interactive mode and some options may cause a problem after a while. Passing the process to the background (& at the end of a command) wasn’t an options because the binary paused execution. So we utilized GNU Screen. We would start Alpine inside a screen, give one second to crash and then kill a running screen.
Our another take was to try crash alpine via mailbox, so we crafted a super simple script with a hope that we’ll find something interesting in the parsing. So we downloaded tons of spam and tried to mutate it with radamsa.
We didn’t found anything, BUT we found a bug with a non-tty file passed a stdin which is described below. :)
After some time of executing the scripts, crashes became to appear. From many repetitive crashes, we extracted a few unique ones.
empty url fragment:
invalid format of last-time-prune-questioned option:
printf formatting characters in option name:
extremely long option name:
crash on file that is not a tty:
Quick analysis of the last bug
the problem is in alpine.c:
if condition is passed by stdin_getc != NULL and args.action = aaFolder:
stdin_getc is set when stdin is not a tty, args.action is set because of -f switch which copies data to args.data:
the problem is that it’s an union and code internally uses args.data.mail.addrlist
which points to the string:
So the bug seems to be caused by the confusion of args.data usage. Exploitability we left as an exercise for you, dear reader!
For the four bugs we created patches. These patches and detailed description of the last crash were sent to the developer responsible for Alpine project. He quickly reacted reviewing and accepting our patches and fixing the fifth crash within a few days! Much more can be done with Alpine, as we didn’t found a way to crash it from the remote.
According to art. 13 of the General Regulation on the Protection of Personal Data of 27 April 2016 (Official Journal EU L 119 of 04.05.2016) I inform that:
1) the administrator of your personal data is Logicaltrust Sp. z o.o. Sp. k. - al. Aleksandra Brücknera 25-43, 51-411 Wrocław,
2) contact with the Personal Data Administrator - email@example.com,
3) Your personal data will be processed for marketing purposes on the basis of Art. 6(1)(a) of the general regulation on the protection of personal data of April 27, 2016..
4) Your personal data will be stored until you withdraw your consent
5) You have the right to request from the administrator access to personal data, the right to rectify their removal or limit processing, the right to withdraw consent and the right to transfer data
6) You have the right to lodge a complaint with the supervisory authority
7) Your data will be processed in an automated manner, including in the form of profiling. Automated decision-making will take place on the principles set out in the regulations (options: subscription, competition, etc.) and the consequence of such processing will be receiving selected marketing information
8) providing personal data is voluntary, however failure to provide data may result in the inability to participate in the newsletter subscription, participate in contests, receive marketing offers, participate in surveys
At the same time, pursuant to Art.6(1)(a) of the general regulation on the protection of personal data of 27 April 2016, I agree to the processing of my personal data for the purpose of subscribing to the newsletter, participation in competitions, receiving marketing offers, participation in surveys