OTG-INPVAL-007 (ORM 인젝션 침투 테스트)


개요

ORM Injection is an attack using SQL Injection against an ORM generated data access object model. From the point of view of a tester, this attack is virtually identical to a SQL Injection attack. However, the injection vulnerability exists in code generated by the ORM tool. An ORM is an Object Relational Mapping tool. It is used to expedite object oriented development within the data access layer of software applications, including web applications. The benefits of using an ORM tool include quick generation of an object layer to communicate to a relational database, standardized code templates for these objects, and usually a set of safe functions to protect against SQL Injection attacks. ORM generated objects can use SQL or in some cases, a variant of SQL, to perform CRUD (Create, Read, Update, Delete) operations on a database. It is possible, however, for a web application using ORM generated objects to be vulnerable to SQL Injection attacks if methods can accept unsanitized input parameters. ORM tools include Hibernate for Java, NHibernate for .NET, ActiveRecord for Ruby on Rails, EZPDO for PHP and many others. For a reasonably comprehensive list of ORM tools, see http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software


테스트 방법


Black Box testing

ORM 인젝션 취약점 블랙박스 테스팅은 SQL 인젝션 테스트와 동일합니다. ORM 레이어에 취약점 대부분이 입력 파라미터를 확인하지 않고 정의한 코드의 결과입니다. 대부분의 ORM 툴툴은 사용자 입력을 빠져나가는 함수를 제공하지만, 만약 이 함수가 사용되지 않고 개발자는 사용자 입력을 받아 함수를 사용하는 경우, SQL 인젝션 공격을 실행하는 것이 가능할 수 있습니다.


Gray Box testing

만약 테스터가 웹 어플리케이션 소스코드에 접근할 수 있거나, ORL 툴의 취약점을 발견할 수 있고 이 툴을 사용한 웹 어플리케이션을 테스트 하는 경우, 어플리케이션에 대한 공격 성공 가능성이 높아질 것입니다.

코드를 찾는 패턴은 다음과 같습니다.

  • SQL 문자열로 연결된 입력 파라미터.

Ruby on Rails를 위한 ActiveRecord를 사용하는 코드

Orders.find_all "customer_id = 123 AND order_date = '#{@
params['order_date']}'"

"' OR 1--" 입력 전송


tools


References

Whitepapers