From 0fe1318d11348a663adc77d1816d0bfd582feb38 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Thu, 27 Aug 2026 19:04:03 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20=EB=8C=80?= =?UTF-8?q?=ED=99=94=ED=98=95=20=ED=94=84=EB=A1=AC=ED=94=84=ED=8A=B8?= =?UTF-8?q?=EC=9D=98=20=EC=A0=95=EC=88=98=20=EC=98=A4=EB=B2=84=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=20=EC=B7=A8=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 - `aFIPC.R`에서 사용자의 입력 값을 `as.integer()`로 강제 변환하기 전 검사하는 정규식을 `^[0-9]+$`에서 `^[12]$`로 수정하여 너무 큰 숫자가 입력되어 정수 오버플로로 인해 `NA`가 반환되고 프로세스가 중단되는 취약점을 수정했습니다. - `.jules/sentinel.md`에 관련된 보안 학습 내용을 기록했습니다. --- .jules/sentinel.md | 5 +++++ R/aFIPC.R | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a48..60237556 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-27 - 대화형 프롬프트의 정수 오버플로 취약점 수정 +**Vulnerability:** 대화형 `readline()` 숫자 입력에 대해 `^[0-9]+$`와 같이 제한 없는 숫자 클래스를 사용하여 검증할 때, 지나치게 큰 숫자 문자열이 정규식 검사를 통과하지만 `as.integer()`에서 `NA`로 평가되어 이후 프로세스 충돌(정수 오버플로 강제 변환 취약점)을 유발할 수 있습니다. +**Learning:** R에서 대화형 숫자 입력을 검증할 때, 제한 없는 숫자 범위보다는 예상되는 정확한 값(예: `^[12]$`)과 일치시켜야 합니다. +**Prevention:** 향후 입력 검증 로직에서는 항상 제한된 길이와 정확한 범위를 확인하도록 정규식을 작성해야 합니다. 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)) } }