From f5d1d56fd61bfa6747aaae59eb18ce0c5e2ecf9a Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Mon, 24 Aug 2026 19:24:08 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[MEDIUM]=20?= =?UTF-8?q?readline=20=EC=A0=95=EA=B7=9C=ED=91=9C=ED=98=84=EC=8B=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EC=A0=95=EC=88=98=20?= =?UTF-8?q?=EC=98=A4=EB=B2=84=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EA=B0=95?= =?UTF-8?q?=EC=A0=9C=20=EB=B3=80=ED=99=98=20=EC=B7=A8=EC=95=BD=EC=A0=90=20?= =?UTF-8?q?=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .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..03ba575f 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-24 - [입력 유효성 검사 강화: 정수 오버플로우 방지] +**Vulnerability:** readline() 수치형 입력값에 대해 단순 숫자 허용 정규표현식(^[0-9]+$)을 사용하여, 지나치게 큰 숫자가 입력될 경우 as.integer() 변환 시 NA가 반환되어 프로세스 크래시 등 예기치 않은 오류가 발생할 수 있습니다. +**Learning:** 사용자 입력은 정확히 예상되는 값(^[12]$)만을 엄격하게 매칭하여 정수 오버플로우 강제 변환(integer overflow coercion) 취약점을 예방해야 함을 배웠습니다. +**Prevention:** 인터랙티브 입력(readline 등) 검증 시 무한정 반복되는 숫자 클래스(^[0-9]+$)를 피하고, 항상 정확하게 일치하는 값만 허용하는 정규표현식을 사용해야 합니다. 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)) } }