Skip to content

Add public_red option and enforce TLP search rules#2927

Open
doomedraven wants to merge 3 commits intomasterfrom
make_red_private
Open

Add public_red option and enforce TLP search rules#2927
doomedraven wants to merge 3 commits intomasterfrom
make_red_private

Conversation

@doomedraven
Copy link
Collaborator

Add a new public_red option to default web config and update perform_search to respect TLP/public_searches settings for non-privileged users. Construct user-specific filters for Elasticsearch and MongoDB searches so RED TLP tasks are hidden from other users unless public_red allows them (or the task belongs to the requesting user). Also adjust source field selection to respect an explicit projection and ensure the Mongo aggregation pipeline includes the same TLP/user_id filtering logic.

Add a new public_red option to default web config and update perform_search to respect TLP/public_searches settings for non-privileged users. Construct user-specific filters for Elasticsearch and MongoDB searches so RED TLP tasks are hidden from other users unless public_red allows them (or the task belongs to the requesting user). Also adjust source field selection to respect an explicit projection and ensure the Mongo aggregation pipeline includes the same TLP/user_id filtering logic.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @doomedraven, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Cuckoo Sandbox web interface by adding a configuration option to manage the visibility of TLP:RED tasks in search results. It also enforces TLP search rules for non-privileged users, ensuring that sensitive tasks are only accessible to authorized personnel. The changes include modifications to both Elasticsearch and MongoDB search queries to incorporate user-specific filters.

Highlights

  • New Configuration Option: Introduced a public_red option in the web configuration to control the searchability of TLP:RED tasks by other users.
  • TLP Enforcement: Implemented logic to filter search results based on TLP markings and user permissions, ensuring non-privileged users only see allowed tasks.
  • User-Specific Filters: Constructed user-specific filters for Elasticsearch and MongoDB searches to hide RED TLP tasks from unauthorized users.
Changelog
  • conf/default/web.conf.default
    • Added a public_red option to control the searchability of TLP:RED tasks.
  • lib/cuckoo/common/web_utils.py
    • Implemented TLP and user-based filtering for Elasticsearch searches.
    • Adjusted MongoDB aggregation pipeline to include TLP and user-based filtering.
    • Modified MongoDB search queries to enforce TLP and user-based access control.
    • Updated Elasticsearch queries to respect explicit projections and apply TLP/user-based filters.
Activity
  • Introduced public_red configuration option.
  • Implemented Elasticsearch filtering based on TLP and user permissions.
  • Modified MongoDB aggregation pipeline for TLP and user-based filtering.
  • Adjusted MongoDB search queries for access control.
  • Updated Elasticsearch queries to respect projections and apply filters.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to control the visibility of TLP:RED tasks for non-privileged users by introducing a public_red configuration and updating Elasticsearch and MongoDB search queries. However, the implementation introduces several security vulnerabilities, including a potential Server-Side Request Forgery (SSRF), a race condition from global state mutation, broken access control in the MongoDB aggregation pipeline, a potential Denial of Service (DoS) in Elasticsearch search, and insecure SSL certificate verification. Furthermore, there is significant code duplication in user-based filter construction for Elasticsearch, and a bug in the MongoDB query logic for anonymous users that could lead to incorrect task visibility.

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