From d8505dc8315f3127aa6864e3c6ff4540e49893ee Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sun, 23 Aug 2026 19:24:32 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20Fix=20integ?= =?UTF-8?q?er=20overflow=20vulnerability=20in=20readline=20input=20validat?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 대화형 프롬프트 입력값 검증 시 무제한 길이를 허용하는 정규식을 사용하여 발생할 수 있는 Integer Overflow 취약점을 수정했습니다. 정규식을 엄격하게 제한하여 보안을 강화했습니다. --- .jules/sentinel.md | 4 ++++ R/aFIPC.R | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a48..692998ef 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -2,3 +2,7 @@ **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-08-23 - [입력값 검증 시 정규식 범위 초과 취약점(Integer Overflow) 수정] +**Vulnerability:** 대화형 프롬프트(예: `readline`) 입력값을 검증할 때 `^[0-9]+$`와 같이 경계가 없는 숫자 정규식을 사용하면, 사용자가 매우 큰 숫자를 입력하여 검증을 통과한 후 `as.integer()`에서 `NA`로 강제 변환되어 후속 로직에서 예외가 발생할 수 있습니다. +**Learning:** R에서 정수를 처리할 때 무제한 길이를 허용하는 정규식은 타입 변환 중 integer overflow 문제를 유발하여 시스템 장애나 예상치 못한 에러를 발생시킬 수 있습니다. +**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)) } }