From 8b0e7e552238837895a4caa8d75d0dd02de8a230 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Tue, 11 Aug 2026 19:32:59 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20=EB=8C=80?= =?UTF-8?q?=ED=99=94=ED=98=95=20=ED=94=84=EB=A1=AC=ED=94=84=ED=8A=B8?= =?UTF-8?q?=EC=9D=98=20=EC=A0=95=EC=88=98=20=EC=98=A4=EB=B2=84=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=EC=B7=A8=EC=95=BD=EC=A0=90=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `R/aFIPC.R`의 `readline()` 입력값 검증을 `grepl("^[0-9]+$", n)`에서 `grepl("^[12]$", n)`으로 변경하여 예상치 못한 과도하게 큰 숫자 입력 시 `as.integer()`에서 발생할 수 있는 정수 오버플로우 및 `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..04aad822 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-08-11 - 대화형 R 프롬프트 입력값 검증 강화 +**Vulnerability:** 대화형 프롬프트(`readline()`)의 입력값을 `grepl("^[0-9]+$", n)`과 같이 검증하면 과도하게 큰 숫자가 입력될 경우 `as.integer()` 과정에서 정수 오버플로우가 발생하여 `NA`로 변환되고 프로세스가 충돌할 수 있는 취약점이 있습니다. +**Learning:** R 스크립트에서 입력값을 받을 때는 예상되는 정확한 값만 받도록 정규표현식을 엄격하게 제한해야 합니다. +**Prevention:** `readline()`을 통한 숫자 입력을 검증할 때 단순한 숫자 패턴(`^[0-9]+$`) 대신 예상되는 값과 정확히 일치하는 패턴(예: `^[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)) } }