From afe20cf15ab1c4f8e4610af7dfdc6aa343dee60e Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sun, 28 Jun 2026 19:13:12 +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=8A=A4=ED=83=9D=20=EC=98=A4=EB=B2=84=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20DoS=20=EC=B7=A8=EC=95=BD=EC=A0=90=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 * `checkCorrect`, `checkoldformBILOGprior`, `checknewformBILOGprior`의 재귀적 `readline()` 호출을 `while` 루프로 변경 * 사용자가 잘못된 입력을 반복적으로 제공할 때 발생하는 C 스택 오버플로우로 인한 세션 크래시(DoS) 방지 --- .jules/sentinel.md | 4 ++++ R/aFIPC.R | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .jules/sentinel.md diff --git a/.jules/sentinel.md b/.jules/sentinel.md new file mode 100644 index 0000000..50425e1 --- /dev/null +++ b/.jules/sentinel.md @@ -0,0 +1,4 @@ +## 2024-06-28 - [Stack Overflow DoS in Interactive Prompts] +**Vulnerability:** Recursive calls to `readline()` in `checkCorrect()`, `checkoldformBILOGprior()`, and `checknewformBILOGprior()` without bounding. +**Learning:** In R, unchecked recursive function calls, especially for user input loops, can cause a C stack overflow, leading to a Denial of Service (session crash). +**Prevention:** Use iterative `while` loops instead of recursion for repeatedly prompting users until valid input is received. diff --git a/R/aFIPC.R b/R/aFIPC.R index b6a9e6c..e321df8 100644 --- a/R/aFIPC.R +++ b/R/aFIPC.R @@ -75,8 +75,8 @@ autoFIPC <- checkCorrect <- function() { n <- readline(prompt = "Is it correct? (1: Yes 2: No) : ") - if (!grepl("^[0-9]+$", n)) { - return(checkCorrect()) + while (!grepl("^[0-9]+$", n)) { + n <- readline(prompt = "Is it correct? (1: Yes 2: No) : ") } return(as.integer(n)) @@ -103,8 +103,11 @@ autoFIPC <- readline( prompt = "Do you want to use default BILOG-MG priors for oldform Data? (1: Yes 2: No) : " ) - if (!grepl("^[0-9]+$", n)) { - return(checkoldformBILOGprior()) + while (!grepl("^[0-9]+$", n)) { + n <- + readline( + prompt = "Do you want to use default BILOG-MG priors for oldform Data? (1: Yes 2: No) : " + ) } return(as.integer(n)) @@ -314,8 +317,11 @@ autoFIPC <- readline( prompt = "Do you want to use default BILOG-MG priors for newform Data? (1: Yes 2: No) : " ) - if (!grepl("^[0-9]+$", n)) { - return(checknewformBILOGprior()) + while (!grepl("^[0-9]+$", n)) { + n <- + readline( + prompt = "Do you want to use default BILOG-MG priors for newform Data? (1: Yes 2: No) : " + ) } return(as.integer(n))