From 209daa0f285f3273202133f626e2808823918774 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 7 Aug 2026 16:16:55 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITIC?= =?UTF-8?q?AL]=20Fix=20weak=20regex=20validation=20leading=20to=20DoS=20in?= =?UTF-8?q?=20readline()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Changed weak regex `^[0-9]+$` to exact match `^[12]$` in readline validations. - This prevents large numbers from causing NA coercions via `as.integer()`. - Added learning to `.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 a8207a4..1dd313d 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-07-13 - Fix weak regex validation leading to DoS +**Vulnerability:** Weak regex `^[0-9]+$` allows large numbers that coerce to `NA` via `as.integer()`, bypassing conditions and causing runtime exceptions. +**Learning:** In R, unbounded integer matching combined with `as.integer()` can create denial-of-service risks due to `NA` coercion. +**Prevention:** Use strictly bounded exact-match regex like `^[12]$` for finite choice prompts to prevent coercion crashes. 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)) } } From c80f28b8c91b5b5c88245d8c0f907e6fa22bcce4 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 7 Aug 2026 16:28:19 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITIC?= =?UTF-8?q?AL]=20Fix=20weak=20regex=20validation=20leading=20to=20DoS=20in?= =?UTF-8?q?=20readline()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Changed weak regex `^[0-9]+$` to exact match `^[12]$` in readline validations. - This prevents large numbers from causing NA coercions via `as.integer()`. - Added learning to `.jules/sentinel.md`. - Added `.semgrepignore` to `.Rbuildignore` to fix `R CMD check` warnings. --- .Rbuildignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.Rbuildignore b/.Rbuildignore index 232504f..388f1c6 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -22,3 +22,4 @@ ^\.jules(/.*)?$ ^\.trivyignore\.yaml$ ^trivy\.yaml$ +^\.semgrepignore$ From 8404700a620daa5bbc71bac876a28cdfcf2e8b82 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 7 Aug 2026 16:46:34 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITIC?= =?UTF-8?q?AL]=20Fix=20weak=20regex=20validation=20leading=20to=20DoS=20in?= =?UTF-8?q?=20readline()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Changed weak regex `^[0-9]+$` to exact match `^[12]$` in readline validations. - This prevents large numbers from causing NA coercions via `as.integer()`. - Added learning to `.jules/sentinel.md`. - Added `.semgrepignore` to `.Rbuildignore` to fix `R CMD check` warnings. From faeccfb84cabfc08531a8cda910b482e395a4b0c Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 7 Aug 2026 17:06:38 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITIC?= =?UTF-8?q?AL]=20Fix=20weak=20regex=20validation=20leading=20to=20DoS=20in?= =?UTF-8?q?=20readline()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Changed weak regex `^[0-9]+$` to exact match `^[12]$` in readline validations. - This prevents large numbers from causing NA coercions via `as.integer()`. - Added learning to `.jules/sentinel.md`. - Added `.semgrepignore` to `.Rbuildignore` to fix `R CMD check` warnings.