Since I started building websites few years ago, I’ve created a few projects. Some of them never saw daylight, some of them were deleted upon creation, some of them still reside in my project archive. When I was trawling through the archive a few days ago, I came across one of them. It was a ticket system I first made back in April 2016 – the whole project was dubbed a “Secure Ticket System” so it instantly caught my attention. I just had to take a look..
Here’s how the system looks like:
As compared to other ticket systems, there are a few things that can be noticed:
The ticket system consisted of four files (excluding the stylesheets and javascript files which were also present):
The system did not use any relational (MySQL) or non-relational (NoSQL) database – as I wanted to try something new at the time, I’ve made it so that the entire system would be based on a flat file database.
I’ll try to make an in-depth analysis of the security of each of the scripts beginning from the top and moving towards the bottom.
The submission process was relatively simple:
When the ticket would be submitted, it would be flagged as “Open” and thus, displayed on the viewing page:
The View.php script would scan the “tickets” directory, get the total count of files which then would be displayed. When the ticket would be submitted and flagged as “Open”, the Index.php script would also write some of the ticket contents to View.php. The script would also allow people who are privileged to view it to respond to the ticket in question:
If the “Close this ticket” checkmark was not checked, the response would be added to the ticket – if it was checked, the ticket would be deleted. This is another downside because with the majority of ticket systems on the web today, when the ticket is closed, a person has a chance to re-open it. My ticket system did not include this feature.
The security of the system was not as bad as I expected it to be: the input of the user was sanitized and thus, it could not trigger an XSS attack, the “tickets” directory was protected by .htaccess. That being said, there were some caveats such as this one:
Wait – is that an SQL error? Yes.
The system operated on a flat file basis, but we still got an SQL error. How? The answer is very simple – it was intentional. As my Web Application Firewall’s SQL injection detection rules were still under heavy development at the time, I wanted to see how effective they were. With that out of the way, we should now probably look at the actual flaws that the system had. One of them was Cross-Site Request Forgery (CSRF):
Since I did not set a CSRF token to validate that the form sent from the browser matches a token on the server, a CSRF attack was possible. The system required the user to be logged in to access the ticket submission page, and, if the appropriate POST parameters could be provided, a CSRF attack could be triggered – an end user could be forced to execute unwanted actions: in this case, submit a ticket.
I failed to protect the form against spam too – this means that anyone could create an automated script to automatically submit tickets.
Now imagine that, for example, tickets #145, #148 and #157 would be created by a legitimate user requesting support, but tickets #146, #147 and #149-#156 would be created by an automated script to spam the system, how would the administrators remove the spam while leaving the legitimate tickets intact?
Since the system was based on a flat-file database, the administrators would have to accomplish this task manually – if the system had hundreds of tickets, the accomplishment of such a task would become almost impossible.
This blog will walk you through some lessons for conference speakers who speak remotely no…
Insecure data storage is the second vulnerability in the OWASP Mobile Top 10 list. Insecure…
The improper platform usage vulnerability is the first vulnerability in the OWASP Mobile Top 10.…
If you ever heard of web application security, you probably heard of OWASP. And if…
If you have ever built a website, chances are you took care of security. Securing…
It's November. For some developers it's just an ordinary month - for some of them…