» tagged pages
» logout

sorted by: recent | see : popular
Content Tagged with PROJECTS + Security

MySQL-Proxy learning to block SQL-Injection

I previously reported about my joy with MySQL-Proxy and a simple SQL-Injection detection based on a simple heuristic.

Today I present the more interesting approach that I promised to publish after my webinar yesterday. This approach is based on the idea that SQL queries issued by an application always have a certain structure. This structure can be learned and remembered by MySQL-Proxy. Any SQL query that has a different structure can then be considered an attack.

Training Mode

The first Lua script learn_sql_queries.lua uses MySQL-Proxy’s read_query hook to catch COM_INIT_DB and COM_QUERY packets. COM_INIT_DB packets are issued when the database is changed and COM_QUERY packets contain normal queries.

When a change of database is detected a CREATE TABLE is injected into the communication to create a table called ‘allowed_queries’ in the newly selected database. This table consist of only on column called ‘query’. Within this column normalized queries are collected.

When a normal query is received it is first tokenized by MySQL-Proxy’s tokenizer. The tokens are then used to recreate a normalized version of the query where all data values are replaced by the ‘?’ placeholder. Additionally IN ( ?, ?, ?, …) statements are compressed to IN ( ? ) to allow arbitrary length IN value lists without having to learn all possibilities. The normalized query is then learned by inserting it into the table.

When all queries have been learned (maybe during development) the blocking mode can be started.

Blocking Mode

The second Lua script block_unknown_queries.lua also uses MySQL-Proxy’s read_query hook to catch COM_INIT_DB and COM_QUERY packets.

When a change of database is detected a SELECT statement is injected into the communication that loads the table ‘allowed_queries’ into a Lua-Table. The queries become the indices so that they can be found fast.

When a normal query is received it is first tokenized and normalized. The normalized Query is then searched in the Lua-Table which is just a key lookup. If the query is found in the table it is one of the known query structures that are allowed. The query is then executed as normally.

If the query is not found in the table it is either a query that was not learned by mistake or it is an SQL-Injection attack. The query is not executed and a database error “Possible SQL Injection” is returned.

Both proof of concept examples are released as GPL. Therefore feel free to modify them for your needs. You might prefer to just log SQL-Injection attempts instead of blocking them.

MySQL: Planet MySQL

Mysql-Proxy Heuristic SQL Injection Detection

?MySQL Proxy is a simple program that sits between your client and MySQL server(s) that can monitor, analyze or transform their communication. Its flexibility allows for unlimited uses; common ones include: load balancing; failover; query analysis; query filtering and modification; and many more.?

The flexibility of MySQL Proxy is based on the fact that every aspect is scriptable with Lua. Because I am new to MySQL Proxy and the Lua language I tried to implement a very simple script that waits for incoming SQL queries, tokenizes them and tries to detect SQL Injection heuristically by searching for certain disallowed SQL functions, databases, tables, statements or comments. When an SQL query is believed to contain an SQL injection is it not executed and a “Possible SQL injection” error is returned.

You can grab the detect_sql_injection.lua script at

http://www.suspekt.org/downloads/detect_sql_injection.lua.gz

If you are interested in this and german speaking you might also be interested in next week’s MySQL webinar “Bau sicherer LAMP Anwendungen” where I will not only discuss this little Lua script but also another one that implements SQL injection detection by query structure learning.

MySQL: Planet MySQL

Web Services Security, Part 3 | webservices.xml.com:

discuss XML-based authentication and the sharing of authentication information across different applications, known<sep/>

XML: del.icio.us/tag/xml

OnSOA Podcast Channel | InformIT: OnSOA (Audio)

The OnSOA Podcast Channel is dedicated to exploring a wide range of topics related to SOA, service-orientation and service-oriented computing. You can expect a new podcast to be released each week.

XML: del.icio.us/tag/xml

Information Sciences Institute (ISI)

The University of Southern California's Information Sciences Institute (ISI) is a major contributor to the nation's information technology knowledge base, and is actively engaged in a broad spectrum of information processing research, as well as the devel

XML: del.icio.us/tag/xml

Information Sciences Institute (ISI)

The University of Southern California's Information Sciences Institute (ISI) is a major contributor to the nation's information technology knowledge base, and is actively engaged in a broad spectrum of information processing research, as well as the devel

W3C: Del.icio.us W3C Tags

Generic Cryptographic Service API (GCS-API) Base | The Open Group: Bookstore & Downloads

This document describes: the Basic GCS-API set of functionality that is expected to meet the cryptographic service requirements of most general applications developers; the Advanced GCS-API additional set of functionality that would only be used by applic

XML: del.icio.us/tag/xml

Generic Cryptographic Service API (GCS-API) Base | The Open Group: Bookstore & Downloads

This document describes: the Basic GCS-API set of functionality that is expected to meet the cryptographic service requirements of most general applications developers; the Advanced GCS-API additional set of functionality that would only be used by applic

W3C: Del.icio.us W3C Tags

KeyboardProc Function ()

Used for KeyLoggers. Make defensive opensource software that lists alll the programs hooking events that allow for keylogging.

opensource: del.icio.us tag/opensource

Securing Web Services with WebLogic Server 9.2

This tutorial discusses the three facets of Web services security: message integrity, message confidentiality, and authentication, and follows this with a comprehensive tutorial on how to implement secure Web services on WebLogic Server.

XML: del.icio.us/tag/xml

Securing Web Services with WebLogic Server 9.2

This tutorial discusses the three facets of Web services security: message integrity, message confidentiality, and authentication, and follows this with a comprehensive tutorial on how to implement secure Web services on WebLogic Server.

W3C: Del.icio.us W3C Tags

Identity management: a developer's view - HP Dev Resource Central

explores the concepts of digital identity management, examines industry-driving trends, discusses various models for deployment, looks at some of the typical functionality found in an identity management system, and describes the typical interfaces availa

XML: del.icio.us/tag/xml

Identity management: a developer's view - HP Dev Resource Central

explores the concepts of digital identity management, examines industry-driving trends, discusses various models for deployment, looks at some of the typical functionality found in an identity management system, and describes the typical interfaces availa

W3C: Del.icio.us W3C Tags

What is GCSx? Explaining GCSx - Welcome to Government Connect | Solutions

GCSx stands for Government Connect Secure eXtranet. It is a private Wide-Area Network (WAN) across which secure GC Solutions GC Mail and GC Exchange run.

XML: del.icio.us/tag/xml

eGovernment Register

This website contains information about e-Government software & hardware products and their use by UK local authorities. Data about e-Government related services, integration and partnerships is also provided.

XML: del.icio.us/tag/xml

Vordel XML Signature API & SAML API. Securing your XML traffic

Vordel's products include a number of useful APIs for core XML security technologies including SAML, WS-Security, and XML Signature.

XML: del.icio.us/tag/xml

XML-Canonical: Canonical XML for Perl - Implements w3 recommendation.

This module provides an implementation of Canonical XML Recommendation (Version 1, 15 March 2001). It uses XML::GDOME for its DOM tree and XPath nodes.

W3C: Del.icio.us W3C Tags

Vordel XML Signature API & SAML API. Securing your XML traffic

Vordel's products include a number of useful APIs for core XML security technologies including SAML, WS-Security, and XML Signature.

W3C: Del.icio.us W3C Tags

Page 1 | Next >>