From 33a0866e4b68f2fc1b55dc6787c1bb1d7829e5ae Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 19 Sep 2026 19:09:58 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[MEDIUM?= =?UTF-8?q?]=20=EC=9E=85=EB=A0=A5=EA=B0=92=20=EC=A0=95=EC=88=98=20?= =?UTF-8?q?=EC=98=A4=EB=B2=84=ED=94=8C=EB=A1=9C=EC=9A=B0(DoS)=20=EC=B7=A8?= =?UTF-8?q?=EC=95=BD=EC=A0=90=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..034d47b5 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 - [정수 오버플로우 방지를 위한 입력값 검증 강화] +**Vulnerability:** 대화형 프롬프트 입력(`readline()`)을 검증할 때 `grepl("^[0-9]+$", n)`과 같은 정규표현식만 사용하면, 매우 큰 숫자 문자열이 정규표현식을 통과한 후 `as.integer()`로 변환될 때 정수 오버플로우를 일으켜 `NA`를 반환하게 되며, 이로 인해 애플리케이션 크래시(DoS)가 발생할 수 있음. +**Learning:** 숫자 문자열 검증 시 허용 가능한 범위를 명시적으로 확인하지 않고 단순 형태학적 검증(정규표현식)에 의존하면 예기치 못한 타입 변환 문제가 발생할 수 있다는 것을 알게 됨. +**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)) } } From 189f37450c6067dc8c80aa36a6cf310f90f23e33 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 26 Sep 2026 16:12:22 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[MEDIUM?= =?UTF-8?q?]=20=EC=9E=85=EB=A0=A5=EA=B0=92=20=EC=A0=95=EC=88=98=20?= =?UTF-8?q?=EC=98=A4=EB=B2=84=ED=94=8C=EB=A1=9C=EC=9A=B0(DoS)=20=EC=B7=A8?= =?UTF-8?q?=EC=95=BD=EC=A0=90=20=EC=88=98=EC=A0=95=20(=EC=88=98=EC=A0=95?= =?UTF-8?q?=20=EC=97=86=EC=9D=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit