Skip to content

Security: a-atalla/cronat

Security

docs/security.md

1️⃣ Webhook Security Risks

🔴 Risk: Webhook URL Leaks (Unauthorized Access)

If a webhook URL is exposed, anyone can send malicious requests to the user's system.

✅ Solution:

  • Encrypt stored webhook URLs in your database. Use Django’s Fernet encryption or PostgreSQL’s pgcrypto.
  • Never expose webhook URLs in API responses.
  • Allow users to configure HMAC signature verification for added security.

🔴 Risk: Webhook Manipulation (Tampering with Data)

If an attacker intercepts a webhook request, they could alter the payload or replay requests to manipulate data.

✅ Solution:

  • Sign webhook requests using an HMAC SHA256 signature with a user-provided secret key.
  • Require HTTPS for all webhook requests (use httpx.Client(verify=True)).
  • Use idempotency keys to prevent replay attacks.

🔴 Risk: Calling Malicious Webhooks (SSRF)

Users could register webhook URLs that point to internal/private services, leading to Server-Side Request Forgery (SSRF) attacks.

✅ Solution:

  • Validate webhook URLs:
    • Block internal IP ranges (e.g., 127.0.0.1, 169.254.169.254).
    • Use DNS resolution checks to ensure the target is an allowed domain.
    • Set network rules to prevent Celery workers from accessing internal services.
    • Limit allowed protocols (only https://, block file://, ftp://).

2️⃣ User Authentication & Access Control

🔴 Risk: Unauthorized Job Modifications

Users could edit or delete cron jobs that don’t belong to them.

✅ Solution:

  • Use JWT-based authentication or API keys for access.
  • Ensure ownership checks in API endpoints:
    • python
    • Copy
    • Edit
    • def get_queryset(self):
      • return ScheduledJob.objects.filter(user=self.request.user)

🔴 Risk: API Key Leaks

If an API key gets leaked, an attacker could abuse the service or modify webhooks.

✅ Solution:

  • Allow users to regenerate API keys at any time.
  • Store API keys hashed (never plaintext).
  • Require HMAC authentication for API calls.

3️⃣ Rate Limiting & Abuse Protection

🔴 Risk: Denial of Service (DoS)

A user could create too many scheduled jobs or trigger high-frequency requests, overwhelming the system.

✅ Solution:

  • Enforce rate limits per user (django-ratelimit or Redis-based limiting).
  • Restrict execution frequency (e.g., prevent running jobs every second).
  • Allow tier-based limits (e.g., free users can schedule jobs every 15 mins, while premium users can do 1 min).

4️⃣ Secure Celery & Task Execution

🔴 Risk: Arbitrary Code Execution

If users can inject arbitrary Python code into Celery tasks, they could execute malicious code on your server.

✅ Solution:

  • Ensure that only predefined tasks can be executed.
  • Do not allow dynamic code execution (e.g., avoid eval(), exec()).

🔴 Risk: Leaked Celery Task IDs

If an attacker gets access to task IDs, they could manipulate execution logs or fake results.

✅ Solution:

  • Never expose Celery task IDs in API responses.
  • Log sensitive details only in internal logs, not in user-facing logs.

5️⃣ Secure Data Storage & Logging

🔴 Risk: Storing Sensitive Data in Logs

If webhook URLs, API keys, or payloads are logged as plain text, they could be exposed.

✅ Solution:

  • Mask sensitive data in logs (e.g., store only https://example.com/... instead of the full URL).
  • Encrypt idempotency keys and webhook payloads.

6️⃣ Deployment & Infrastructure Security

🔴 Risk: Unsecured Redis & Celery Setup

If Redis is exposed publicly, attackers could flush jobs, modify tasks, or steal sensitive data.

✅ Solution:

  • Use Redis authentication and restrict access to localhost/VPC.
  • Use TLS encryption for Redis.

🔴 Risk: Unprotected Admin Panel

If Django admin is left open, attackers could gain access.

✅ Solution:

  • Restrict Django admin access (e.g., IP whitelisting, VPN).
  • Use strong authentication (2FA, enforced strong passwords).

🔎 Summary: How to Secure Your Cron Job SaaS

✅ Encrypt & protect webhook URLs ✅ Validate webhook destinations (block SSRF, internal network access) ✅ Authenticate all API calls (JWT, API keys, HMAC) ✅ Limit execution frequency & enforce rate limits ✅ Prevent code injection in Celery tasks ✅ Secure Redis & Celery configurations ✅ Harden admin access & logging

There aren't any published security advisories