From 12cb79590c58fbad143e0e801919fd451b30cf3e Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 29 Aug 2026 19:03:03 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[MEDIUM?= =?UTF-8?q?]=20readline=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20=EA=B2=80=EC=82=AC?= =?UTF-8?q?=EC=97=90=EC=84=9C=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=EB=AC=B8=EC=A0=9C=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..7dd8e1b0 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-18 - [Fix integer overflow in readline validation] +**Vulnerability:** `readline()` 입력을 검증할 때 `^[0-9]+$` 정규식을 사용하여, 사용자가 정수 표현 범위를 초과하는 숫자를 입력하면 `as.integer()`가 `NA`를 반환하는 취약점이 존재했습니다. +**Learning:** 범위가 지정되지 않은 숫자 정규식 매칭은 매우 긴 문자열이 입력되었을 때 정수 강제 형변환(coercion) 시 프로세스가 비정상 종료되는 원인이 될 수 있습니다. +**Prevention:** `readline()`과 같은 상호작용 입력의 경우, 허용되는 정확한 값들(예: `^[12]$`)만 매칭하도록 정규식을 엄격하게 제한해야 합니다. 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)) } } From 024e6b805d9b5722152d03965f33a50c675086b4 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 29 Aug 2026 19:13:46 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[MEDIUM?= =?UTF-8?q?]=20readline=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20=EA=B2=80=EC=82=AC?= =?UTF-8?q?=EC=97=90=EC=84=9C=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=EB=AC=B8=EC=A0=9C=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, 3 insertions(+), 7 deletions(-) diff --git a/.jules/sentinel.md b/.jules/sentinel.md index 7dd8e1b0..a8207a48 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -2,7 +2,3 @@ **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-18 - [Fix integer overflow in readline validation] -**Vulnerability:** `readline()` 입력을 검증할 때 `^[0-9]+$` 정규식을 사용하여, 사용자가 정수 표현 범위를 초과하는 숫자를 입력하면 `as.integer()`가 `NA`를 반환하는 취약점이 존재했습니다. -**Learning:** 범위가 지정되지 않은 숫자 정규식 매칭은 매우 긴 문자열이 입력되었을 때 정수 강제 형변환(coercion) 시 프로세스가 비정상 종료되는 원인이 될 수 있습니다. -**Prevention:** `readline()`과 같은 상호작용 입력의 경우, 허용되는 정확한 값들(예: `^[12]$`)만 매칭하도록 정규식을 엄격하게 제한해야 합니다. diff --git a/R/aFIPC.R b/R/aFIPC.R index 918e19b1..62546519 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("^[12]$", n)) { + if (grepl("^[0-9]+$", 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("^[12]$", n)) { + if (grepl("^[0-9]+$", 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("^[12]$", n)) { + if (grepl("^[0-9]+$", n)) { return(as.integer(n)) } }