diff --git a/Cargo.lock b/Cargo.lock index 4397a09..67c3570 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -875,6 +875,7 @@ dependencies = [ "sentry", "serde", "serde_json", + "tokio", "tracing", "tracing-actix-web", "tracing-appender", @@ -3122,9 +3123,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.42.0" +version = "1.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165" dependencies = [ "backtrace", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 2f94962..158bef6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,4 +36,5 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-actix-web = "0.7" tracing-log = "0.2" tracing-appender = "0.2" -tracing-bunyan-formatter = "0.3" \ No newline at end of file +tracing-bunyan-formatter = "0.3" +tokio = "1.45.0" diff --git a/README.md b/README.md index b74a4f2..250f569 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ The application can be configured using environment variables or a configuration - `SENTRY_DSN`: Sentry DSN for error tracking - `JWT_SECRET`: JWT secret key - `JWT_EXPIRATION`: JWT expiration time in seconds +- `CAPTCHA_ENABLED`: Enable CAPTCHA verification for public form submissions (`true` or `false`, default: `false`) +- `CAPTCHA_SECRET_KEY`: The secret key provided by your CAPTCHA service (e.g., hCaptcha, reCAPTCHA) +- `CAPTCHA_VERIFICATION_URL`: The verification endpoint URL for your CAPTCHA service (e.g., `https://hcaptcha.com/siteverify`) ## Development @@ -144,6 +147,17 @@ tail -f logs/app.log - Passwords are hashed using bcrypt - SQLite database is protected with proper file permissions +### Form Submission Security + +The public form submission endpoint (`/api/forms/{form_id}/submissions`) includes several security measures: + +- **Global Rate Limiting:** The overall number of requests to the API is limited. +- **Per-Form, Per-IP Rate Limiting:** Limits the number of submissions one IP address can make to a specific form within a time window (e.g., 5 submissions per minute). Configurable in code. +- **CAPTCHA Verification:** If enabled via environment variables (`CAPTCHA_ENABLED=true`), requires a valid CAPTCHA token (e.g., from hCaptcha, reCAPTCHA, Turnstile) to be sent in the `captcha_token` field of the submission payload. The backend verifies this token with the configured provider. +- **Payload Size Limit:** The maximum size of the submission payload is limited (e.g., 1MB) to prevent DoS attacks. Configurable in code. +- **Input Validation:** Submission data is validated against the specific form's field definitions (type, required, length, pattern, etc.). +- **Notification Throttling:** Limits the rate at which notifications (Email, Ntfy) are sent per form to prevent spamming channels (e.g., max 1 per minute). Configurable in code. + ## License MIT diff --git a/frontend/index.html b/frontend/index.html index e7f8172..74f4b26 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -67,7 +67,7 @@