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
5 changes: 5 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@
**Vulnerability:** Raw `stop()` and `warning()` calls without `call. = FALSE` in `llcont.R` and `vuongtest.R` exposed execution stack/call details when raised.
**Learning:** While some instances of `stop()` inside `tryCatch()` were previously fixed to hide the call stack, other standalone exceptions and warnings still leaked call context. Security must be consistently applied across the entire codebase.
**Prevention:** Always set `call. = FALSE` when using `stop()` or `warning()` to enforce a secure-by-default boundary and prevent internal execution paths from being disclosed to the end user.

## 2024-07-28 - Prevent Information Disclosure via Unvalidated Inputs
**Vulnerability:** Publicly exported functions `icci()` and `vuongtest()` did not validate user inputs like `conf.level`, `nested`, and `adj`. Invalid inputs (e.g., `NA` or wrong types) bypassed top-level safeguards and triggered raw R errors deep inside internal logic (e.g., `if (nested)` failing with "missing value where TRUE/FALSE needed" or `qnorm` failing with "NaNs produced"), leaking internal execution contexts.
**Learning:** Unvalidated arguments passed to exported functions can cause fatal errors deep in the codebase, bypassing `stop(..., call. = FALSE)` safeguards and exposing internal stack contexts to users.
**Prevention:** Always strictly validate the type, length, and bounds of user inputs at the very beginning of exported functions and fail securely using `stop("...", call. = FALSE)`.
3 changes: 3 additions & 0 deletions R/icci.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
#' @importFrom stats AIC var qnorm
#' @export
icci <- function(object1, object2, conf.level=.95, ll1=llcont, ll2=llcont) {
if (length(conf.level) != 1 || !is.numeric(conf.level) || is.na(conf.level) || conf.level <= 0 || conf.level >= 1) {
stop("conf.level must be a single numeric value strictly between 0 and 1.", call. = FALSE)
}

## check objects, issue warnings/errors, get classes/calls
obinfo <- check.obj(object1, object2)
Expand Down
6 changes: 6 additions & 0 deletions R/vuongtest.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
#' @importFrom methods slotNames
#' @export
vuongtest <- function(object1, object2, nested=FALSE, adj="none", ll1=llcont, ll2=llcont, score1=NULL, score2=NULL, vc1=vcov, vc2=vcov) {
if (length(nested) != 1 || !is.logical(nested) || is.na(nested)) {
stop("nested must be a single logical value (TRUE or FALSE).", call. = FALSE)
}
if (length(adj) != 1 || !is.character(adj) || is.na(adj) || !(adj %in% c("none", "aic", "bic"))) {
stop('adj must be a single character string: "none", "aic", or "bic".', call. = FALSE)
Comment on lines +103 to +104

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ“ Info: adj now validated even when nested=TRUE

Docs state adj is ignored when nested=TRUE, but the new check at vuongtest.R rejects invalid adj regardless of nested. A call like vuongtest(m1, m2, nested=TRUE, adj=<junk>) that previously ran now errors. Likely intended, noted for awareness.

Open in Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

}

## check objects, issue warnings/errors, get classes/calls
obinfo <- check.obj(object1, object2)
Expand Down
Loading