가이드라인

주사 기초 가이드

가장 잘 알려진 취약점 유형 중 하나는 인젝션 취약점이며, 그중에서도 단연 독보적인 존재는 바로 SQL 인젝션입니다. 기술 분야에서 SQL 인젝션에 대해 들어보지 않기가 어려울 정도이니, 이에 대해 자세히 알아보겠습니다.

SQL 인젝션을 사용하면 SQL 쿼리의 동작을 조작하여 공격자가 원하는 대로 실행하게 만들 수 있습니다.

겉보기에는 달라 보이지만 모두 동일한 원리로 작동하는 다른 여러 유형의 인젝션도 존재합니다.

요약하자면, 가장 일반적인 인젝션 유형은 다음과 같습니다.

  • SQL 인젝션
  • 크로스 사이트 스크립팅(HTML/자바스크립트 인젝션)
  • 경로 탐색(경로/URL 인젝션)
  • 명령어 인젝션
  • 코드 인젝션

인젝션 101 기초

앞서 나열한 인젝션 유형들을 살펴보면 한 가지 공통점이 있습니다. 모두 인터프리터를 통해 실행되는 문자열을 포함하며, 인터프리터는 해당 문자열이 나타내는 작업을 수행한다는 점입니다. 중괄호로 표시된 부분이 "사용자 입력"입니다.

Type Example input How it’s interpreted
SQL SELECT name FROM users WHERE username = '{admin}' Selects the "Name" column from all rows from the users table where the username is 'admin'
HTML {John Smith} Shows the name "John Smith" in bold letters
Path /var/www/app/documents/{privacy-policy.pdf} Points at the file `privacy-policy.pdf` in the `/var/www/app/documents/` folder
Command ping {8.8.8.8} Sends a series of ICMP pings to the IP `8.8.8.8`
Code const name = '{John Smith}'; Sets the constant variable `name` to the value `John Smith

그렇다면 사용자 입력 삽입이 안전하지 않을 경우 어떤 일이 벌어질까요? 공격자는 무엇을 할 수 있을까요? 다시 한번 강조하지만, 이 시나리오에서 중괄호 안의 모든 내용은 "사용자 입력"으로 간주됩니다.

Type Example input How it’s interpreted
SQL - Injected SELECT name FROM users WHERE username = '{1' UNION SELECT passwordhash from users WHERE username = 'admin}' Selects the "Name" from all rows from the users table where the username is 'admin', and the password hash for the users where the username is 'admin'
HTML - Injected {} Show the name "John Smith" in bold letters
Path - Injected /var/www/app/documents/{../../../../../etc/shadow} Points at the file `shadow` in the `/etc/` folder
Command - Injected ping {8.8.8.8 && ls . } Sends a series of ICMP pings to the IP `8.8.8.8`, and prints the contents of the current directory with `ls`
Code - Injected const name = '{John Smith'; exec('ls .'); # }'; Sets the constant variable `name` to the value `John Smith`, and then executes the system command `ls .

이 예시들에서 사용자 입력이 어떻게 결과에 영향을 미칠 수 있는지 주목해 보세요.

이것이 바로 인젝션의 본질입니다. 인터프리터에 전달되는 내용을 조작하여 원래 프로그래머가 의도하지 않은 동작을 수행하도록 만드는 것입니다.

이것은 고려해야 할 기본 사항일 뿐입니다. 더 자세히 다룰 필요가 있는 몇 가지 인젝션 유형은 별도의 페이지로 분리해 두었습니다.

다음 링크에서 확인하실 수 있습니다:

명령어 인젝션‍

경로 탐색‍

SQL 인젝션‍

크로스 사이트 스크립팅

태그라인

실무에 바로 적용하는 보안 코딩

OWASP Top 10과 같은 소프트웨어 취약점을 이해하고 완화하기 위한 보안 코딩 가이드라인을 살펴보고, 실제 앱 시뮬레이션을 통해 실습할 수 있는 가이드형 교육 미션을 시작해 보세요.

추가 가이드라인
데모 예약하기