Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@
^\.jules(/.*)?$
^\.trivyignore\.yaml$
^trivy\.yaml$
^\.jules$
^\.jules/.*
8 changes: 4 additions & 4 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 6 additions & 3 deletions R/aFIPC.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down Expand Up @@ -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))
}
}
Expand Down Expand Up @@ -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))
}
}
Expand Down
Loading