From 722889a8080f257adba9da719cf58183b8a093c5 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 18 Sep 2026 19:22:49 +0000 Subject: [PATCH] =?UTF-8?q?=EC=9E=85=EB=A0=A5=EA=B0=92=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=ED=96=A5=EC=83=81=EC=9D=84=20=ED=86=B5=ED=95=9C=20?= =?UTF-8?q?=EC=A0=95=EC=88=98=20=EC=98=A4=EB=B2=84=ED=94=8C=EB=A1=9C?= =?UTF-8?q?=EC=9A=B0(DoS)=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jules/sentinel.md | 4 ++++ R/aFIPC.R | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a48..c9dd5a21 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. +## 2023-10-25 - [입력값 검증 취약점 수정] +**Vulnerability:** `readline()`으로 받은 입력을 정수로 변환할 때 단순 정규식(`grepl("^[0-9]+$", n)`)만 사용하여, 매우 큰 숫자가 입력될 경우 오버플로우로 인해 `NA`가 반환되어 시스템 충돌(DoS)을 유발할 수 있음. +**Learning:** 단순 패턴 매칭은 타입 변환의 안전성을 보장하지 않음. R에서는 특히 `as.integer()` 변환 시 범위를 초과하면 `NA`로 강제 변환되므로 로직 오류의 원인이 됨. +**Prevention:** 사전에 정의된 유효한 옵션 값들의 집합과 정확히 일치하는지(`%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)) } }