From 5162841c0f1e15b5e92cb85e98a2340daf98a195 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 17 Jul 2026 16:17:29 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITICAL]?= =?UTF-8?q?=20=EC=9E=85=EB=A0=A5=20=EA=B0=92=20=EA=B0=95=EC=A0=9C=20?= =?UTF-8?q?=EB=B3=80=ED=99=98=EC=97=90=20=EC=9D=98=ED=95=9C=20DoS=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의 `readline` 입력값 확인 중 약한 정규표현식 `^[0-9]+$`이 쓰여 비정상적으로 긴 입력값이 들어왔을 때 `as.integer()`에서 `NA`로 강제 변환되어 충돌 또는 무한루프(DoS)가 유발될 수 있는 취약점을 수정함. 엄격한 정규표현식 `^[12]$`을 사용하여 보안 및 안정성을 강화함. --- .Rbuildignore | 2 ++ .jules/sentinel.md | 8 ++++---- R/aFIPC.R | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 232504f..c2e551e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -22,3 +22,5 @@ ^\.jules(/.*)?$ ^\.trivyignore\.yaml$ ^trivy\.yaml$ +^\.jules$ +^\.jules/.* diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a4..c497d8c 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -1,4 +1,4 @@ -## 2024-07-12 - Fix missing parameter validations -**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-07-17 - Weak Regex Validation Coercion DoS +**Vulnerability:** Weak regex `^[0-9]+$` used to validate integer input allows excessively large numbers to be entered. When parsed by `as.integer()`, they are coerced to `NA`, bypassing validation and causing runtime crashes or infinite loops when used in `if` conditions. +**Learning:** The legacy implementation used greedy validation that didn't consider the maximum bounds of `integer` types in R, relying blindly on base numeric characters rather than specific valid options. +**Prevention:** Use strictly bounded exact-match regex (like `^[12]$`) for discrete choice options to prevent `NA` coercion and subsequent Denial of Service risks. diff --git a/R/aFIPC.R b/R/aFIPC.R index 6254651..0cda2f0 100644 --- a/R/aFIPC.R +++ b/R/aFIPC.R @@ -141,7 +141,8 @@ autoFIPC <- } for (attempt in seq_len(3)) { n <- readline(prompt = "Is it correct? (1: Yes 2: No) : ") - if (grepl("^[0-9]+$", n)) { + # SECURITY: Strictly bounded exact-match regex to prevent DoS from NA coercion of large numbers + if (grepl("^[12]$", n)) { return(as.integer(n)) } } @@ -171,7 +172,8 @@ autoFIPC <- readline( prompt = "Do you want to use default BILOG-MG priors for oldform Data? (1: Yes 2: No) : " ) - if (grepl("^[0-9]+$", n)) { + # SECURITY: Strictly bounded exact-match regex to prevent DoS from NA coercion of large numbers + if (grepl("^[12]$", n)) { return(as.integer(n)) } } @@ -390,7 +392,8 @@ autoFIPC <- readline( prompt = "Do you want to use default BILOG-MG priors for newform Data? (1: Yes 2: No) : " ) - if (grepl("^[0-9]+$", n)) { + # SECURITY: Strictly bounded exact-match regex to prevent DoS from NA coercion of large numbers + if (grepl("^[12]$", n)) { return(as.integer(n)) } }