결과 화면 XSS 출력 인코딩 적용 - #3
Open
hchanhi wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
변경 내용
인라인
<%= %>로 사용자 입력(Request.Form)을 인코딩 없이 출력하던 결과 화면에 출력 인코딩을 적용했습니다.Server.HtmlEncode적용._PAY_RESULT자바스크립트 문자열 컨텍스트에HttpUtility.JavaScriptStringEncode적용.Server.HtmlEncode적용.REMOTE_ADDR를 자바스크립트 문자열에 넣던 부분에HttpUtility.JavaScriptStringEncode적용.손대지 않은 것
Request.Form[...]에서 직접 오는 원본 값이므로(별도 인코딩 계층 없음) 이번 인코딩이 유일한 처리이며 이중 인코딩은 발생하지 않습니다.PG_MID,PAYMENT_SERVER등 상수 출력은 사용자 입력이 아니므로 변경하지 않았습니다.cancel_showResult.aspx.cs)의Label.Text출력은 ASP.NET이 자동 HTML 인코딩하므로 안전하여 변경하지 않았습니다.검증
이 샘플은 ASP.NET WebForms(.NET Framework)라 리눅스/macOS 환경에서 웹앱 전체를 실행할 수 없어, 적용한 인코딩 함수의 동작을 .NET 콘솔로 단위 검증했습니다.
HttpUtility.HtmlEncode/HttpUtility.JavaScriptStringEncode모두 정상 값(영문 코드, 숫자, 한글)에 대해 원본과 동일한 출력(무영향) 확인."</script><script>...&)에 대해 HTML은 엔티티로, JS는\uXXXX로 이스케이프되어 원시<script>/</script>가 사라지는 것 확인.