From b2332d3dddcefe14373d096cfc8546772b2facf0 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Tue, 25 Aug 2026 18:58:01 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20Fix=20integ?= =?UTF-8?q?er=20overflow=20vulnerability=20in=20readline=20validation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 대화형 프롬프트(`readline()`)의 입력값을 검증하는 정규식을 `^[0-9]+$`에서 `^[12]$`로 변경하여 정수 오버플로우로 인해 예상치 못한 `NA` 값이 발생하는 취약점을 방지했습니다. - `.jules/sentinel.md` 파일에 해당 보안 취약점 패턴과 예방 방법에 관한 학습 내용을 문서화했습니다. --- .jules/sentinel.md | 5 +++++ R/aFIPC.R | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a48..1fd0f299 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -2,3 +2,8 @@ **Vulnerability:** Unvalidated inputs passed to `if()` statements can cause process crashes (`condition has length > 1`) or unexpected coercion vulnerabilities. **Learning:** In R, optional boolean parameters that default to `NULL` should be validated using explicit runtime type validation (e.g., `if (!is.null(flag) && (!is.logical(flag) || length(flag) != 1 || is.na(flag)))`). **Prevention:** Always implement explicit runtime type validation for optional boolean parameters. + +## 2024-05-18 - [입력값 검증 시 정수 오버플로우 방지] +**Vulnerability:** 대화형 프롬프트(`readline()`)의 숫자 입력 검증 시 제한 없는 정규식(`^[0-9]+$`)을 사용하여 매우 큰 수가 입력될 경우 `as.integer()`에서 `NA`로 평가되는 정수 오버플로우 취약점이 있었습니다. +**Learning:** 기대하는 입력값이 한정적일 때 광범위한 숫자 클래스 패턴 일치를 허용하면 다운스트림 함수(예: 변환 함수)에서 예기치 않은 동작이나 충돌을 유발할 수 있음을 확인했습니다. +**Prevention:** 대화형 프롬프트나 폼 검증 시에는 예상되는 값을 정확히 매칭하는 엄격한 정규식(예: `^[12]$`)을 사용하여 허용 범위를 명확히 제한해야 합니다. diff --git a/R/aFIPC.R b/R/aFIPC.R index 62546519..918e19b1 100644 --- a/R/aFIPC.R +++ b/R/aFIPC.R @@ -141,7 +141,7 @@ autoFIPC <- } for (attempt in seq_len(3)) { n <- readline(prompt = "Is it correct? (1: Yes 2: No) : ") - if (grepl("^[0-9]+$", n)) { + if (grepl("^[12]$", n)) { return(as.integer(n)) } } @@ -171,7 +171,7 @@ autoFIPC <- readline( prompt = "Do you want to use default BILOG-MG priors for oldform Data? (1: Yes 2: No) : " ) - if (grepl("^[0-9]+$", n)) { + if (grepl("^[12]$", n)) { return(as.integer(n)) } } @@ -390,7 +390,7 @@ autoFIPC <- readline( prompt = "Do you want to use default BILOG-MG priors for newform Data? (1: Yes 2: No) : " ) - if (grepl("^[0-9]+$", n)) { + if (grepl("^[12]$", n)) { return(as.integer(n)) } }