Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Security: Stop Denied/Pending ChallengeHost rows from retaining host privileges - #5194

Draft
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/application-security-review-881f
Draft

Security: Stop Denied/Pending ChallengeHost rows from retaining host privileges#5194
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/application-security-review-881f

Conversation

@cursor

@cursor cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Description

is_user_a_host_of_challenge / get_challenge_host_teams_for_user previously treated any ChallengeHost row as active hostship, ignoring status. After a host was Denied (or left Pending/Unknown), they could still call host-gated APIs and retrieve cluster secrets (kube_config, EKS bearer tokens).

This change aligns hostship checks with Accepted/Self only (matching get_challenge_host_required_error and participant host helpers), and updates related call sites.

Finding

  • Severity: High
  • Location: apps/hosts/utils.py
  • Attack path: Denied/Pending ChallengeHost row → host APIs still authorize → evaluation cluster credentials / host mutations remain available

Changes

  • Introduce ACTIVE_HOST_STATUSES = (Accepted, Self) and filter hostship helpers
  • Use the helpers from challenge list POST, submission detail authz, host team list, and submission serializer host PK cache
  • Add unit tests for Denied/Pending/Self status handling

Tests

  • pytest tests/unit/hosts/ (50 passed)
  • pytest tests/unit/challenges/test_permissions.py tests/unit/participants/test_utils.py (25 passed)
  • black/isort check on touched files (clean)
Open in Web View Automation 

Denied/Pending host membership rows previously still unlocked host APIs
via is_user_a_host_of_challenge, including kubeconfig and EKS tokens.
Align hostship checks with Accepted/Self only.

Co-authored-by: Rishabh Jain <[email protected]>
@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.30%. Comparing base (d1b8469) to head (39da14f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5194   +/-   ##
=======================================
  Coverage   91.30%   91.30%           
=======================================
  Files         115      115           
  Lines        8996     8997    +1     
=======================================
+ Hits         8214     8215    +1     
  Misses        782      782           
Flag Coverage Δ
backend 93.85% <100.00%> (+<0.01%) ⬆️
frontend 87.54% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Accounts & Authentication 97.40% <ø> (ø)
Challenges Management 96.19% <ø> (ø)
Job Processing 90.19% <ø> (ø)
Participants & Teams 99.54% <ø> (ø)
Challenge Hosts 100.00% <100.00%> (ø)
Analytics 100.00% <ø> (ø)
Web Interface 100.00% <ø> (ø)
Frontend (Gulp) 87.54% <ø> (ø)
All Models 97.37% <ø> (ø)
All Views 100.00% <ø> (ø)
All Serializers 98.20% <ø> (ø)
Utility Functions 97.30% <100.00%> (+<0.01%) ⬆️
Core Configuration 78.94% <ø> (ø)
Files with missing lines Coverage Δ
apps/challenges/views.py 100.00% <ø> (ø)
apps/hosts/utils.py 100.00% <100.00%> (ø)
apps/hosts/views.py 100.00% <ø> (ø)
apps/jobs/serializers.py 100.00% <ø> (ø)
apps/jobs/views.py 100.00% <ø> (ø)
Files with missing lines Coverage Δ
apps/challenges/views.py 100.00% <ø> (ø)
apps/hosts/utils.py 100.00% <100.00%> (ø)
apps/hosts/views.py 100.00% <ø> (ø)
apps/jobs/serializers.py 100.00% <ø> (ø)
apps/jobs/views.py 100.00% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d1b8469...39da14f. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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