diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a48..e3edb70c 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-08-21 - 입력 검증에서 발생할 수 있는 정수 오버플로우 취약점 패치 +**Vulnerability:** 대화형 `readline()` 함수에서 `grepl("^[0-9]+$")`와 같이 길이에 제한이 없는 정규표현식을 사용하여 숫자를 검증할 경우, 매우 긴 숫자가 입력되었을 때 `as.integer()` 변환 과정에서 오버플로우가 발생하거나 NA가 반환되어 이후 프로세스에서 크래시가 발생할 수 있습니다. +**Learning:** R 스크립트에서 입력값을 검증할 때는 사용자의 입력이 기대하는 값과 정확히 일치하는지 확인해야 합니다. (예: `^[12]$`) +**Prevention:** `readline()`과 같은 입력을 검증할 때는 가능한 값의 범위나 형태를 정확하게 지정하는 정규표현식을 사용하여 입력 범위를 엄격하게 제한해야 합니다. diff --git a/R/aFIPC.R b/R/aFIPC.R index 62546519..918e19b1 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)) } }