diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a48..2a229da6 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -2,3 +2,7 @@ **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-05-24 - [대화형 프롬프트의 정수 오버플로 취약점(DoS) 수정] +**Vulnerability:** 대화형 프롬프트에서 `grepl("^[0-9]+$", n)` 정규식을 사용해 입력을 검증한 후 `as.integer()`로 변환할 때, 매우 큰 숫자가 입력되면 R에서 정수 오버플로가 발생하여 `NA`가 반환되고 애플리케이션 크래시가 일어날 수 있습니다. +**Learning:** R에서 사용자 입력(문자열)을 정수로 강제 변환할 때, 단순 정규식 검증은 큰 수에 대한 오버플로를 방어하지 못하며 치명적인 에러로 이어질 수 있습니다. +**Prevention:** 지정된 선택지만 있는 경우, 정규식보다는 `n %in% c("1", "2")`와 같은 정확한 일치 검사를 수행해야 합니다. diff --git a/R/aFIPC.R b/R/aFIPC.R index 62546519..118aca09 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 (n %in% c("1", "2")) { 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 (n %in% c("1", "2")) { 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 (n %in% c("1", "2")) { return(as.integer(n)) } }