Hackers of India

Injecting Security into Web apps with Runtime Patching and Context Learning

By  Ajin Abraham  on 03 Mar 2017 @ Nullcon


Presentation Material

Abstract

Web Application Security is not hard, but it’s easy to get it wrong as writing secure code is not easy as preaching. So to overcome incidents happening from such unforeseen events, organisations tend to rely on Web Application Firewalls or WAFs. Web Application Firewalls have been in the industry for a long time. Every one of them either work outside or around the web applications and act by intercepting the HTTP request coming to the web server, then take a decision to allow or block the request based on traditional signature checks. They are never aware of what is happening inside the application like how the user input is getting interpreted, Is the application/server under heavy load?, Is the attacker exfiltrating data by exploiting an SQLi that WAF couldn’t detect? etc. The strength of traditional WAF depends on manual or predefined rules/signature. As a result, they have the limitation that they will get bypassed if a payload is not present in their signature list. In the occurrence of a zero day, a WAF in most cases won’t be able to prevent an attack as they don’t know the signature of the exploit yet.

In this talk I will share my research outcomes on implementing a runtime application patching algorithm on an insecurely coded application to make it secure against code injection vulnerabilities and other logical issues related to web applications. I will introduce the next generation web application defending technology dubbed as Runtime Application Self Protection (RASP) that works by understanding your application to defend against web attacks by working inside the web application. RASP relies on Runtime Patching to inject security into web apps implicitly without introducing additional code changes. The root cause of all the code injection vulnerabilities is that the language interpreter cannot distinguish between data and code. The proposed solution will detect code context breakout to effectively detect and prevent code injections with the help of runtime hooking and patching at framework api or language api level. The research focuses mainly on detecting and preventing vulnerabilities like SQL Injection, Cross Site Scripting, Remote Command Execution, HTTP Verb Tampering, Header Injection etc and other application security challenges like Session Hijacking, Credential Stuffing and Layer 7 DDoS etc. This research is carried out by implementing a RASP module to a vulnerable web application written in python using tornado framework with sqlite backend.

I will discuss the following methodologies with proof of concept code and demo:

AI Generated Summarymay contain errors

Here is a summarized version of the content:

The speaker is an expert in a specific technology and works for a large company. They want to set expectations around water loss fees and how their algorithm works, prevent session hijacking, (e.g., identifying a session as coming from a specific user). The goal is to find the best possible solution, , not just a half-solution.

The speaker explains that they are using a technique called monkey patching to secure APIs,. They import packets and create whitelists by hooking into API execution, generating rules before commands are executed. This approach allows for seamless security without needing separate security logic.

When discussing ORMs (Object-Relational Mappers), the speaker emphasizes that their technology can work with any ORM, as it hooks into the lowest level of database interaction, extracting SQL queries and providing a standardized representation.

The conversation also touches on templating frameworks and HTML escaping. The speaker notes that some frameworks, like Django, require custom escaping functionality, while others, like Google Closure, have context-specific escaping built-in.

Overall, the speaker is showcasing their technology’s capabilities and emphasizing the importance of finding perfect solutions rather than half-measures.