From c5a6c4f210da624c675a75ae85e7a267c3915dfa Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sun, 26 Jul 2026 19:14:04 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITIC?= =?UTF-8?q?AL]=20=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=EC=9D=98=20=EC=A0=95=EC=88=98=20=EC=98=A4=EB=B2=84?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EA=B0=95=EC=A0=9C=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=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 R/aFIPC.R 파일 내 readline() 함수를 통한 대화형 입력 처리 시 정규표현식 `^[0-9]+$`를 `^[12]$`로 수정하여 예상치 못한 입력으로 인한 정수 오버플로우 및 애플리케이션 충돌 취약점을 방지합니다. --- .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 a8207a4..3a95580 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-07-26 - Fix interactive input integer overflow coercion +**Vulnerability:** Interactive `readline()` prompts previously used unbounded digit matching (`^[0-9]+$`), which allowed users to input extremely large numeric strings that would pass the regex check but result in an `NA` evaluation when passed to `as.integer()`. This can lead to unexpected type coercion issues or application crashes. +**Learning:** For interactive command-line interfaces using `readline()`, strictly bounding the expected input (e.g., `^[12]$`) prevents integer overflow coercion vulnerabilities. +**Prevention:** Use strictly defined regex boundaries for expected options instead of arbitrary length numeric classes when asking for categorical numeric input via `readline()`. 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 bcf0900d03963600baa56cef3ca9cdd051fbaa3f Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sun, 26 Jul 2026 19:29:48 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITIC?= =?UTF-8?q?AL]=20=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=EC=9D=98=20=EC=A0=95=EC=88=98=20=EC=98=A4=EB=B2=84?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EA=B0=95=EC=A0=9C=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=20=EC=B7=A8=EC=95=BD=EC=A0=90=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20R=20CMD=20check=20=EA=B2=BD=EA=B3=A0=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `readline()` 대화형 입력 검증 시 정수 오버플로우 및 크래시를 유발할 수 있는 느슨한 정규표현식(`^[0-9]+$`)을 엄격한 경계 조건(`^[12]$`)으로 수정 - 패키지 빌드 시 발생하는 불필요한 숨김 파일 경고 해결을 위해 `.Rbuildignore`에 `.semgrepignore` 및 `test_*.R` 패턴 추가 - 최상위 디렉토리에 포함되어 `R CMD check` 경고를 유발하는 `test_dummy.R`, `test_validation.R` 테스트 파일 삭제 --- .Rbuildignore | 2 ++ test_dummy.R | 2 -- test_validation.R | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 test_dummy.R delete mode 100644 test_validation.R diff --git a/.Rbuildignore b/.Rbuildignore index 232504f..c645350 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -22,3 +22,5 @@ ^\.jules(/.*)?$ ^\.trivyignore\.yaml$ ^trivy\.yaml$ +^\.semgrepignore$ +^test_.*\.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") From 741fe3572327c6cdd10b4a67c913ace309520d74 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sun, 26 Jul 2026 19:38:03 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITIC?= =?UTF-8?q?AL]=20=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=EC=9D=98=20=EC=A0=95=EC=88=98=20=EC=98=A4=EB=B2=84?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EA=B0=95=EC=A0=9C=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=20=EC=B7=A8=EC=95=BD=EC=A0=90=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20R=20CMD=20check=20=EA=B2=BD=EA=B3=A0=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `readline()` 대화형 입력 검증 시 정수 오버플로우 및 크래시를 유발할 수 있는 느슨한 정규표현식(`^[0-9]+$`)을 엄격한 경계 조건(`^[12]$`)으로 수정 - 패키지 빌드 시 발생하는 불필요한 숨김 파일 경고 해결을 위해 `.Rbuildignore`에 `.semgrepignore` 및 `test_*.R` 패턴 추가 - 최상위 디렉토리에 포함되어 `R CMD check` 경고를 유발하는 `test_dummy.R`, `test_validation.R` 테스트 파일 삭제 From 3321013242043a1f82abea6f1f679e5d3309b2e3 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sun, 26 Jul 2026 19:47:26 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITIC?= =?UTF-8?q?AL]=20=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=EC=9D=98=20=EC=A0=95=EC=88=98=20=EC=98=A4=EB=B2=84?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EA=B0=95=EC=A0=9C=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=20=EC=B7=A8=EC=95=BD=EC=A0=90=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20R=20CMD=20check=20=EA=B2=BD=EA=B3=A0=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `readline()` 대화형 입력 검증 시 정수 오버플로우 및 크래시를 유발할 수 있는 느슨한 정규표현식(`^[0-9]+$`)을 엄격한 경계 조건(`^[12]$`)으로 수정 - 패키지 빌드 시 발생하는 불필요한 숨김 파일 경고 해결을 위해 `.Rbuildignore`에 `.semgrepignore` 및 `test_*.R` 패턴 추가 - 최상위 디렉토리에 포함되어 `R CMD check` 경고를 유발하는 `test_dummy.R`, `test_validation.R` 테스트 파일 삭제