Skip to content

Workspace: Add dojo Command-Line Application#964

Merged
ConnorNelson merged 41 commits intopwncollege:masterfrom
TheodorKitzenmaier:cli2
Jan 20, 2026
Merged

Workspace: Add dojo Command-Line Application#964
ConnorNelson merged 41 commits intopwncollege:masterfrom
TheodorKitzenmaier:cli2

Conversation

@TheodorKitzenmaier
Copy link
Contributor

@TheodorKitzenmaier TheodorKitzenmaier commented Oct 22, 2025

Overview

Adds a command line application, dojo, which allows for limited interaction with a custom set of integration APIs. The application authenticates using the DOJO_AUTH_TOKEN environment variable, which has been changed to be a set of signed values tying the token to the user and their current challenge.

In order to allow for communication between the application and the dojo, challenge containers have been given network access to the nginx container. In theory the iptables configuration in dojo/dojo-init should ensure that this is the only other container that the challenge containers can access, but someone more familiar with iptables should sanity check this.

Integrations

Added a new namespace to the pwn.college api, integrations. Endpoints within the integrations namespace expect requests to use the auth_token AuthToken header to provide the current container's authentication token.

Command

whoami

A simple command which prints out information about the current user. Prints the user's name and id.

Invoked by calling dojo whoami in a terminal.

Container auth token is now a signed token instead of a random byte string.
- The server signs the account id, challenge id, and an additional string.
- The challenge ID is included to ensure that the token matches the active challenge.

This allows for verification of the owner of the token and efficient authentication of challenge containers.
Changed return from just the user id to both the user and challenge ids.
- Required for challenge matching.
Added the API endpoint for use by internal container integration.

Key features:
- Gets an authentication token from request headers (auth_token).
- Performs authentication that the token is correctly signed and matches the active challenge container.
- API calls create a session for the duration of the request.
    - The session is destroyed upon completion of the request.
CTFD is open with IP 10.0.0.117.
- iptables configured to accept connections from 10.0.0.0/8 (challenge containers?) to 10.0.0.117 (ctfd).
If we were to use the before/teardown_request decorators, it would have to be applied to the entire application.
- The overhead of this seems excessive, and I see no advantage in running the session teardown check on every endpoing.
- Why Flask does not offer the ability to specify before/after/teardown at the namespace level, I do not know.
Challenge containers now communicate with the nginx container instead of the ctfd container.
Added a python application, starting with a whoami command.
Added a testcase for the dojo cli application.
- WHOAMI command is tested to ensure it returns the name of the random user.
Switched from URLSafeSerializer to URLSafeTimedSerializer to ensure that container tokens are only valid for the maximum lifespan of a container.
dojo-cli.nix is at ./core, not ./code...
Switched from `Requests` to `Urllib`.
Custom auth token header isn't showing up for some reason.
Switched from using auth_token as header to AuthToken.
- Headers with underscores are dropped?

Fixed incorrect signing of container token.
- Docker was incorrectly using `challenge.challenge_id` instead of `challenge.id`.
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
dojo_plugin/api/v1/user.py 86.66% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Improved error handling of CLI application.

Create an `apiRequest` function with "robust" error handling for use in later versions.
Attempt to allow challenge containers to communicate with the main dojo node.
- Open 192.168.42.1 to challenge containers.
@TheodorKitzenmaier TheodorKitzenmaier marked this pull request as ready for review November 12, 2025 19:55
Copy link

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

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.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ConnorNelson
Copy link
Member

  • Let's change dojo-cli so its not inlined in a nix file, its in its own file (with nice syntax highlighting, etc).
  • Let's get rid of integration.py, instead lets have a wrapper that we apply to other end points. For example, @authed_only is the standard CTFd wrapper, you added @authed. Lets rename @authed to @authed_only_cli, which can handle the @authed_only mechanism of authentication AND also the container-based auth-token. Then for the endpoints we want to make available to cli, we'll swap the @authed_only to a @authed_only_cli.

TODO for me is to further investigate the networking.

TheodorKitzenmaier and others added 14 commits January 6, 2026 11:59
Split dojo-cli into a nix installer and a seperate py file.
- Now we get highlighting! Hooray!
Modified CLI Auth Wrapper to be usable on normal API functions.
- This will allow normal API endpoints to be used by the container.
Updated user/me api endpoint to give limited user info to containers.

Added cli attribute to container sessions.
- Allows APIs to limit some functionality if a container is making the request.
Removed redundant iptables rule for specific source and destination.
@ConnorNelson
Copy link
Member

@codex Please fix any python styling issues, e.g. userID, challengeID.

@chatgpt-codex-connector
Copy link

Codex couldn't complete this request. Try again later.

@ConnorNelson
Copy link
Member

@codex Please fix any python styling issues, e.g. userID, challengeID.

@chatgpt-codex-connector
Copy link

Codex couldn't complete this request. Try again later.

@ConnorNelson ConnorNelson force-pushed the cli2 branch 4 times, most recently from 1b10ecd to 9d6c82d Compare January 20, 2026 21:43
@ConnorNelson ConnorNelson changed the title Add dojo Command-Line Application Workspace: Add dojo Command-Line Application Jan 20, 2026
@ConnorNelson ConnorNelson merged commit b0d032b into pwncollege:master Jan 20, 2026
4 of 7 checks passed
@zardus
Copy link
Member

zardus commented Jan 21, 2026 via email

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.

3 participants