Skip to content

🔒 [security fix] Secure task deletion and detailed access with per-task tokens#5

Closed
QuenumGerald wants to merge 1 commit into
mainfrom
security-fix-task-deletion-auth-1397686978802999609
Closed

🔒 [security fix] Secure task deletion and detailed access with per-task tokens#5
QuenumGerald wants to merge 1 commit into
mainfrom
security-fix-task-deletion-auth-1397686978802999609

Conversation

@QuenumGerald

Copy link
Copy Markdown
Owner

🔒 Security Fix: Comprehensive Task Protection

🎯 What: This PR secures the task management API by protecting sensitive data and operations using a per-task token system.

⚠️ Risk:

  1. Unauthorized Deletion: Anyone could delete tasks, disrupting automation.
  2. Data Leakage: The global task list exposed sensitive configurations (like blockchain parameters or API keys in HTTP tasks).

🛡️ Solution:

  • Per-Task Tokens: Each task now gets a secure 32-character hex token generated via crypto.randomBytes.
  • Filtered List View: GET /tasks is now restricted to metadata (ID, status, timing). Sensitive config data is removed from the bulk list.
  • Protected Detail View: A new GET /task/:id endpoint allows authorized users to see full details (including config) by providing the correct token.
  • Secure Deletion: Deletion now requires the x-task-token header for all tasks that possess a token.
  • Zero-Config & Backward Compatible: Legacy tasks continue to work without tokens, and no manual environment setup is required for new users.

This dual-layered approach (filtering + token-based detail access/deletion) provides robust security while maintaining a smooth developer experience.


PR created automatically by Jules for task 1397686978802999609 started by @QuenumGerald

- Automatically generate a cryptographically secure random token (deleteToken) for each new task.
- Secure DELETE /task/:id: requires x-task-token header if a token is set for the task.
- Secure GET /task/:id: new endpoint providing full task details, also requiring x-task-token.
- Privacy for GET /tasks: filtered to return only non-sensitive metadata (config and tokens are hidden).
- Full backward compatibility: legacy tasks without tokens remain accessible without additional headers.
- Automatic database migration to add the deleteToken column.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a6f3e333c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/index.ts
config ? JSON.stringify(config) : null,
webhookUrl
webhookUrl,
deleteToken

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Generate delete tokens inside schedule() by default

schedule() now persists deleteToken exactly as provided, but the only generator was added in the HTTP POST /task handler, so other first-party creation paths (for example src/bin/cli.ts schedule command and scheduleManyCosmosQueries) still insert NULL tokens for new tasks. Since both protection checks are conditional on task.deleteToken being truthy, those newly created tasks remain readable/deletable without any x-task-token, which bypasses the security model for non-HTTP scheduling flows.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant