From a2db6a4069273ede442a4d32981d90d6e4c44f34 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 29 Aug 2026 04:03:28 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[MEDIUM?= =?UTF-8?q?]=20Fix=20input=20validation=20missing=20in=20exported=20functi?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added strict type, length, and bounds validation at the beginning of exported functions to fail securely using stop(..., call. = FALSE). --- .jules/sentinel.md | 4 ++++ R/icci.R | 4 ++++ R/vuongtest.R | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/.jules/sentinel.md b/.jules/sentinel.md index bc5c6e1..a3c71af 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -12,3 +12,7 @@ **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-05-18 - Missing Input Validation in Exported Functions +**Vulnerability:** User inputs passed to exported functions like `vuongtest` and `icci` lacked strict type and length validation (e.g., `nested=c(TRUE, FALSE)`). +**Learning:** R's lazy evaluation and conditional structures (like `if`) can cause raw errors (e.g., "condition has length > 1") deep inside the logic when unvalidated inputs are processed, bypassing top-level `stop(..., call. = FALSE)` safeguards and leaking internal execution context. +**Prevention:** Always strictly validate the type, length, and bounds of user inputs at the very beginning of exported functions using `stop(..., call. = FALSE)` to ensure a secure boundary and prevent information disclosure. diff --git a/R/icci.R b/R/icci.R index f22278a..323f3a9 100644 --- a/R/icci.R +++ b/R/icci.R @@ -65,6 +65,10 @@ #' @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("The 'conf.level' argument must be a single numeric value between 0 and 1.", call. = FALSE) + } + ## check objects, issue warnings/errors, get classes/calls obinfo <- check.obj(object1, object2) callA <- obinfo$callA; classA <- obinfo$classA diff --git a/R/vuongtest.R b/R/vuongtest.R index 2bdfbf6..ddf2390 100644 --- a/R/vuongtest.R +++ b/R/vuongtest.R @@ -98,6 +98,13 @@ #' @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("The 'nested' argument must be a single logical value (TRUE or FALSE).", call. = FALSE) + } + if (length(adj) != 1 || !is.character(adj) || !(adj %in% c("none", "aic", "bic"))) { + stop("The 'adj' argument must be a single string ('none', 'aic', or 'bic').", call. = FALSE) + } + ## check objects, issue warnings/errors, get classes/calls obinfo <- check.obj(object1, object2) callA <- obinfo$callA; classA <- obinfo$classA From b8502ac1dfcf4833e549fdee81c321c2b07a680a Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 29 Aug 2026 04:06:30 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[MEDIUM?= =?UTF-8?q?]=20Fix=20input=20validation=20missing=20in=20exported=20functi?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added strict type, length, and bounds validation at the beginning of exported functions to fail securely using stop(..., call. = FALSE).