CVE-2026-118669(OAuthLib 토큰 부여 client_id 혼동)의 오프라인 교육용 모델
CVE-2026-118669(GHSA-7984-qgvg-3j9c)의 오프라인 모델: OAuthLib 4.0.0 이전 버전에서 토큰 grant 핸들러는 request.client를 하나의 클라이언트로 인증하지만, 요청 본문에서 공격자가 제공한 client_id를 유지하여 validate_grant_type() 및 validate_scopes()에 전달합니다. low로 인증하고 client_id=high를 전송하는 클라이언트는 애플리케이션 validator가 client_id 인수로 권한을 부여할 때 grant 및 scope 검사가 high로 실행됩니다. 커밋 c951a1d09f99(pre = 수정 전, post = 수정 후)에서 수정되었으며, 4.0.0에서 릴리스되었습니다.
교육용, 오프라인, 결정적, Python 표준 라이브러리만 사용합니다. oauthlib은 설치되거나 import되지 않으며, HTTP 요청이 이루어지지 않습니다. validator는 GHSA PoC의 인메모리 데모(low: scopes read; high: read admin)에 batch를 더한 것으로, client_credentials만 허용됩니다.
스페인어: README.es.md. 연습문제: PRACTICE.md.
| Diff 줄 | pre | post |
|---|---|---|
117-124, 130 (client_credentials) | authenticate_client, 속성 검사, 본문 client_id로 validate_grant_type, 그 다음 client_id = client_id or client.client_id | grant 검사 전에 validate_client_confidential (125) |
165, 180-184, 190-191 (password) | create_token_response에서 클라이언트 인증; validate_grant_type 후에 채움 | validate_token_request (173) 내부의 validate_client_authentication |
23-28 (authorization_code), 150-152 (refresh_token), 235-243 (device_code) | 누락된 경우에만 채움; refresh에는 속성 검사 없음 | 제거됨; 바인딩은 base.py에서 발생 |
| 41-61 / 63-81 (base.py, 추가됨) | — | 인증 후: client에 client_id가 있어야 함 (52-56 / 72-76); 누락된 client_id는 채워짐 (58-59 / 78-79); 다른 값이면 ServerError 발생 (60-61 / 80-81) |
| 83-105 (base.py) | 인라인 기밀/공개 검사 (87-103) | 두 헬퍼로 디스패치 |
| 296-324, 345-353 (tests) | — | 불일치 → ServerError, 누락된 속성 → NotImplementedError |
base.py validate_grant_type / validate_scopes(수정 사항에 의해 변경되지 않음, diff에 없음)는 수정 전 파일에서 읽었습니다. SOURCES.md를 참조하세요.
results/cases.tsv)| Case | pre | post |
|---|---|---|
p01 GHSA PoC, client_credentials, 인증 low, 본문 client_id=high, scope=admin | TOKEN_SPLIT: low로 인증됨, grant 및 scope가 high로 검사됨, admin 부여됨 | ServerError (125; 58-61) |
p02 password와 동일 | TOKEN_SPLIT | ServerError (173; 58-61) |
p03 batch(password grant 없음)가 client_id=high 전송 | TOKEN_SPLIT | ServerError |
p05 공개 클라이언트, validator가 다른 클라이언트를 설정 | TOKEN_SPLIT | ServerError (173; 78-81) |
p06-p08 device / authorization code / refresh | STAGE_OK_SPLIT | ServerError |
n01, n02 GHSA 대조군(client_id=low, admin) | InvalidScopeError | 동일 |
a01 본문에 client_id 없음, 정책 arg | UnauthorizedClientError (grant가 None으로 검사됨) | TOKEN |
a03 validator가 request.client로 권한 부여 | TOKEN_SPLIT (low의 scopes, 토큰은 high로 기록됨) | ServerError |
*_SPLIT은 요청이 request.client_id가 request.client.client_id와 다른 상태로 완료되었음을 의미합니다. STAGE_OK는 코드 / refresh-token / device-code 검사가 모델링되지 않은 grant에 대해 모델링된 단계가 통과했음을 의미합니다.
스윕(results/sweep.csv, 7,200개 케이스): post는 절대 분할로 끝나지 않습니다. 모든 post 성공은 request.client_id == request.client.client_id를 가집니다. 모든 pre 분할은 ServerError 또는 NotImplementedError가 됩니다. 본문 client_id가 인증된 클라이언트와 같을 때 수정 사항은 아무것도 변경하지 않습니다.
모델 관찰 사항, 발견 사항 아님: pre에서 본문에 client_id가 없는 client_credentials 요청은 validate_grant_type(None, …)을 호출하며(diff:130의 채움은 권한 부여 확인 이후에 발생), 따라서 인자로 권한을 부여하는 검증기는 이를 거부합니다(a01). client_id이 없는 클라이언트 객체와 함께 pre refresh_token을 실행하면 diff:151-152에서 그대로 AttributeError이 발생합니다. 둘 다 데모 검증기에 의존합니다.
python3 tests/run.py # any skip = failure
python3 scripts/derive_expected.py | diff - fixtures/expected.tsv
python3 scripts/derive_expected.py sweep | diff - results/sweep.csv
PYTHONPATH=src python3 -m oauthlib_model results fixtures/cases.tsv /tmp/r && diff -r results /tmp/r
PYTHONPATH=src python3 -m oauthlib_model case pre client_credentials confidential low auth high admin - arg
fixtures/cases.tsv에는 수동 레이블이 저장되어 있으며, scripts/derive_expected.py은 모델을 가져오지 않고 플랫 단계 목록에서 모든 행을 다시 도출합니다. 테스트는 세 가지를 모두 비교합니다.
LIMITATIONS.md와 SOURCES.md를 참조하세요. 라이선스: Apache-2.0.