From 3b47a1ef78a082974f612fd53c94d6b6fdd1be18 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sun, 19 Jul 2026 19:03:18 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITICAL]?= =?UTF-8?q?=20=EB=8C=80=ED=99=94=ED=98=95=20=ED=94=84=EB=A1=AC=ED=94=84?= =?UTF-8?q?=ED=8A=B8=EC=9D=98=20=EC=A0=95=EC=88=98=20=EC=98=A4=EB=B2=84?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=20=EA=B0=95=EC=A0=9C=20=EB=B3=80=ED=99=98=20?= =?UTF-8?q?=EC=B7=A8=EC=95=BD=EC=A0=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R/aFIPC.R 파일 내의 `readline()` 입력을 검증하는 정규 표현식(`^[0-9]+$`)을 의도된 입력 값인 '1' 또는 '2'만 정확히 일치시키는 `^[12]$`로 수정하여, 비정상적으로 큰 숫자 문자열이 입력되었을 때 발생하는 정수 오버플로 및 `as.integer()` 변환 후 `NA` 반환으로 인한 다운스트림 로직 오류 및 프로세스 충돌 취약점을 방지했습니다. --- .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..3255af5 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-24 - [CRITICAL] Prevent Integer Overflow Coercion in Interactive Prompts +**Vulnerability:** Interactive `readline()` prompt validations were using unbounded digit classes (`^[0-9]+$`) to match single-digit numeric inputs (e.g., "1" or "2"). +**Learning:** This approach enables integer overflow coercion vulnerabilities. When an excessively large numeric string is passed, it matches the regex but evaluates to `NA` when coerced via `as.integer()`. This allows unexpected values to bypass the validation and can cause subsequent process crashes (Denial of Service) when passed to downstream logic expecting a valid integer. +**Prevention:** Strictly match against the exact expected values (e.g., `^[12]$`) rather than unbounded digit classes when validating interactive `readline()` numeric inputs. 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)) } }