From ef9e2d724d0c7633eaa72aadcd3c2688ab051796 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Wed, 22 Jul 2026 19:10:32 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[MEDIUM]=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=EA=B0=92=20=EA=B2=80=EC=A6=9D=EC=9D=98=20?= =?UTF-8?q?=EC=A0=95=EA=B7=9C=EC=8B=9D=EC=9D=84=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=ED=95=98=EC=97=AC=20=EC=A0=95=EC=88=98=20=EC=98=A4=EB=B2=84?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=EC=9A=B0=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 `readline()`의 입력값 검증 정규표현식을 `^[0-9]+$`에서 `^[12]$`로 수정하여, 의도하지 않은 거대한 정수 문자열 입력 시 발생하는 Integer Overflow Coercion Vulnerability를 방지함. --- .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 a8207a4..834ecda 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-05-18 - [CRITICAL] Prevent Integer Overflow Coercion in readline Input Validation +**Vulnerability:** Interactive `readline()` prompts for binary choices (e.g., '1' or '2') in `autoFIPC` incorrectly validated input using the unbounded regular expression `^[0-9]+$`. This allows arbitrarily large numeric strings (e.g., "999999999999999999999") to pass the regex check, which subsequently evaluates to `NA` when coerced via `as.integer()`, potentially causing unhandled exceptions or process crashes. +**Learning:** The previous validation implementation used `^[0-9]+$` allowing unbounded numeric digits, assuming `as.integer()` would handle it securely. However, R's `as.integer()` returns `NA` with a warning for out-of-range large integers, which leaks into subsequent logic that expects an integer. +**Prevention:** Strictly limit allowed character patterns matching exact expected literal values (e.g., `^[12]$`) instead of generic type structures (e.g., all digits) when validating string inputs bound for type coercion or conditionals. diff --git a/R/aFIPC.R b/R/aFIPC.R index 6254651..918e19b 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)) } }