diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a4..d789709 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -1,4 +1,5 @@ -## 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. +## 2026-07-21 - Fix integer overflow coercion vulnerabilities in interactive prompts + +**Vulnerability:** Interactive prompts using `readline()` validated numeric inputs with `^[0-9]+$`, which allowed excessively large numeric strings to pass the regex check but evaluate to `NA` when coerced with `as.integer()`. This unhandled `NA` would cause process crashes when used in conditional statements. +**Learning:** In R, unbounded numeric regex validation (`^[0-9]+$`) coupled with `as.integer()` coercion is insufficient for exact matching and can lead to unhandled integer overflow exceptions. +**Prevention:** Strictly match interactive numeric inputs against exact expected values (e.g., `^[12]$`) instead of unbounded digit classes to prevent both unexpected values and integer overflow coercion vulnerabilities. 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)) } }