From f01f984907c39e18a7f94cbc37be618fcfca09a9 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 24 Jul 2026 19:15:49 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20?= =?UTF-8?q?=EB=8C=80=ED=99=94=ED=98=95=20=EC=9E=85=EB=A0=A5=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20=EC=A0=95?= =?UTF-8?q?=EC=88=98=20=EC=98=A4=EB=B2=84=ED=94=8C=EB=A1=9C=EC=9A=B0=20?= =?UTF-8?q?=EA=B0=95=EC=A0=9C=20=EB=B3=80=ED=99=98=20=EC=B7=A8=EC=95=BD?= =?UTF-8?q?=EC=A0=90(integer=20overflow=20coercion=20vulnerability)=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `readline()` 입력 유효성 검증 정규식을 `^[0-9]+$`에서 `^[12]$`로 변경하여 예상치 못한 입력에 대해 더 강력하게 대응할 수 있도록 했습니다. --- .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 a8207a4..f906381 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-07-24 - [CRITICAL] Fix integer overflow coercion vulnerability in interactive inputs +**Vulnerability:** Interactive `readline()` prompts for binary choices (1 or 2) used unbounded digit class regex (`^[0-9]+$`). If a user provided an excessively large numeric string, it would pass the validation check but could evaluate to `NA` when passed to `as.integer()`, leading to process crashes downstream. +**Learning:** In R, converting strings representing integers larger than R's `.Machine$integer.max` using `as.integer()` results in `NA` and raises a warning. If this result isn't explicitly handled for `NA` values, it can lead to coercion vulnerabilities and unexpected behaviors. +**Prevention:** When validating numeric strings for known bounded choices (e.g., 1 or 2), strictly match the exact expected values in the regex (e.g., `^[12]$`) instead of simply checking for numeric formats (`^[0-9]+$`). diff --git a/R/aFIPC.R b/R/aFIPC.R index 6254651..918e19b 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)) } } From 1c1abeeba566ade6765025181eabf500bad09d3d Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 24 Jul 2026 19:26:10 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20`.Rbuil?= =?UTF-8?q?dignore`=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EB=B0=8F=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=20=EA=B0=95=EC=A0=9C=20=EB=B3=80=ED=99=98=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 R CMD check 과정에서 `.semgrepignore` 파일이 패키지 빌드에 포함되어 발생하는 NOTE(GitHub Actions CI에서는 에러로 처리됨)를 해결하기 위해 `.Rbuildignore` 파일에 `^\.semgrepignore$`를 추가했습니다. 또한, 이전 커밋에서 수정한 대화형 입력(`readline()`)의 정규식 검증 로직(`^[0-9]+$` -> `^[12]$`)을 포함합니다. --- .Rbuildignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.Rbuildignore b/.Rbuildignore index 232504f..388f1c6 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -22,3 +22,4 @@ ^\.jules(/.*)?$ ^\.trivyignore\.yaml$ ^trivy\.yaml$ +^\.semgrepignore$ From 87e0a79db1c3b182ecf2599253444e6e16d3594a Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 24 Jul 2026 19:36:47 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20`.Rbuil?= =?UTF-8?q?dignore`=EC=97=90=20=EC=8A=A4=ED=81=AC=EB=9E=98=EC=B9=98?= =?UTF-8?q?=ED=8C=A8=EB=93=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80=ED=95=98=EC=97=AC=20CI=20?= =?UTF-8?q?=EB=B9=8C=EB=93=9C=20=EC=8B=A4=ED=8C=A8=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 패키지 최상위 디렉토리에 존재하는 `test_dummy.R`, `test_validation.R` 파일들이 `R CMD check --as-cran` 단계에서 "Non-standard files/directories found at top level" 경고/에러를 발생시켰습니다. 이를 해결하기 위해 해당 파일들을 `.Rbuildignore`에 추가하여 패키지 빌드 시 무시하도록 조치했습니다. --- .Rbuildignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.Rbuildignore b/.Rbuildignore index 388f1c6..28b2d85 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -23,3 +23,5 @@ ^\.trivyignore\.yaml$ ^trivy\.yaml$ ^\.semgrepignore$ +^test_dummy\.R$ +^test_validation\.R$ From 10c806703eaeb60be8d993d83e1df7d5f934b870 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 24 Jul 2026 19:49:13 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20?= =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=9E=98=EC=B9=98=ED=8C=A8=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=ED=8C=8C=EC=9D=BC=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F?= =?UTF-8?q?=20CI=20=EB=B9=8C=EB=93=9C=20=EC=8B=A4=ED=8C=A8=20=EC=B5=9C?= =?UTF-8?q?=EC=A2=85=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 패키지 최상위 디렉토리에 존재하던 `test_dummy.R`, `test_validation.R` 파일들이 `R CMD check --as-cran` 단계에서 "Non-standard files/directories found at top level" 에러를 발생시켰습니다. 해당 파일들은 로컬 테스트용 스크래치패드로 판단되므로 삭제하여 문제를 완전히 해결했습니다. --- test_dummy.R | 2 -- test_validation.R | 3 --- 2 files changed, 5 deletions(-) delete mode 100644 test_dummy.R delete mode 100644 test_validation.R diff --git a/test_dummy.R b/test_dummy.R deleted file mode 100644 index e6f7019..0000000 --- a/test_dummy.R +++ /dev/null @@ -1,2 +0,0 @@ -source("R/aFIPC.R") -source("R/surveyFA.R") diff --git a/test_validation.R b/test_validation.R deleted file mode 100644 index f084116..0000000 --- a/test_validation.R +++ /dev/null @@ -1,3 +0,0 @@ -source("R/aFIPC.R") -source("R/surveyFA.R") -print("Syntax check passed")