XML 및 LDAP 인젝션 방지
SQL과 명령어를 넘어 XML(XXE)과 LDAP까지 인젝션 방어를 확장해 보세요. 신뢰할 수 없는 입력이 이러한 해석기를 손상시키는 방식과 이를 무력화하는 방법을 익혀 보세요.
XML 및 LDAP 인젝션 방지은(는) CoddyKit의 무료 Secure Coding & OWASP Top 10 for Backend 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Secure Coding & OWASP Top 10 for Backend 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Secure Coding & OWASP Top 10 for Backend 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Injection Beyond SQL
You have seen SQL, command, and XSS injection. Any interpreter that mixes untrusted input with structure is at risk. Two often-missed backend targets are XML parsers and LDAP directories.
What Is XXE
XML External Entity (XXE) injection abuses XML parsers that resolve external entities. An attacker defines an entity that reads a local file or hits an internal URL.
<!DOCTYPE x [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>
<data>&xxe;</data>What XXE Can Do
- Read sensitive files from the server
- Perform server-side request forgery to internal services
- Cause denial of service via entity expansion
All from a parser feature most apps never need.
Disable External Entities
The core fix is to configure the parser to not resolve external entities or DTDs. This single setting closes XXE entirely.
factory.setFeature('http://apache.org/xml/features/disallow-doctype-decl', true);
factory.setExpandEntityReferences(false);Prefer Safer Formats
Where possible, accept JSON instead of XML — it has no entity concept and no equivalent attack. If you must take XML, lock the parser down first.
What Is LDAP Injection
LDAP directories are queried with filter strings. If user input is concatenated into a filter, an attacker can alter the query logic — the LDAP analog of SQL injection.
// vulnerable: input goes straight into the filter
filter = '(uid=' + username + ')'An LDAP Bypass
Submitting * or admin)(&) as a username can turn a precise filter into one that matches many entries or always succeeds, bypassing authentication.
Escape LDAP Special Characters
Neutralize the special characters * ( ) \ NUL by escaping them before they enter a filter.
def escape(s):
out = ''
for ch in s:
if ch in '*()\\':
out += '\\' + format(ord(ch), '02x')
else:
out += ch
return outUse Parameterized APIs
Best of all, use directory APIs that accept inputs as parameters rather than building filter strings by hand — the same principle that makes prepared SQL statements safe.
The Common Defense
Across SQL, command, XML, and LDAP the rule is identical: never let untrusted input change the structure of a query or document. Separate code from data with parameterization, escaping, or safe parser config.
Allow-List Validation
Add a layer of defense by validating input against an allow-list of acceptable values before it reaches any interpreter. Rejecting unexpected characters or formats early shrinks the attack surface for every injection class at once.
import re
if not re.fullmatch(r'[a-zA-Z0-9_.-]+', username):
raise ValueError('invalid username')Quick Check
Test your injection defense.
Recap
You extended injection defense to XML and LDAP:
- XXE abuses external entities — disable DTDs and entity resolution
- LDAP injection manipulates filters — escape special characters or use parameterized APIs
- The universal rule: keep untrusted data out of structure
자주 묻는 질문
“XML 및 LDAP 인젝션 방지” 강의는 무료인가요?
네 — “XML 및 LDAP 인젝션 방지” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Secure Coding & OWASP Top 10 for Backend 강의 전체를 잠금 해제할 수 있습니다. Secure Coding & OWASP Top 10 for Backend 강의에는 총 4개의 강의가 포함되어 있습니다.
“XML 및 LDAP 인젝션 방지”에서 뭘 배우나요?
SQL과 명령어를 넘어 XML(XXE)과 LDAP까지 인젝션 방어를 확장해 보세요. 신뢰할 수 없는 입력이 이러한 해석기를 손상시키는 방식과 이를 무력화하는 방법을 익혀 보세요. 브라우저에서 직접 실행하는 실습 코드로 Secure Coding & OWASP Top 10 for Backend을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Secure Coding & OWASP Top 10 for Backend을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Secure Coding & OWASP Top 10 for Backend은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“XML 및 LDAP 인젝션 방지” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Secure Coding & OWASP Top 10 for Backend 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Secure Coding & OWASP Top 10 for Backend 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- SQL 삽입 방지
- 명령어 및 코드 삽입
- 백엔드의 사이트 간 스크립팅(XSS)
- XML 및 LDAP 인젝션 방지