Skip to content

Restrict access to partial configuration information to read-only users #7455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

guidomodarelli
Copy link
Contributor

@guidomodarelli guidomodarelli commented May 22, 2025

Description

In certain configurations, authenticated users with read-only API roles may retrieve agent enrollment credentials through the /utils/configuration endpoint. These credentials can be used to register new agents within the same Wazuh tenant without requiring elevated permissions through the UI.

Users with authenticated access and the appropriate RBAC profile may access the configuration API. This endpoint returns a JSON payload that includes the enrollment.password and enrollment.dns fields used to register agents.

Despite lacking agent:create permissions via the user interface, these credentials may be used manually to register additional agents via command-line or automation scripts.

Example of retrieved information by a read-only user:

{
    "statusCode": 200,
    "error": 0,
    "data": {
        "alerts.sample.prefix": "wazuh-alerts-4.x-",
        "checks.api": true,
        "checks.fields": true,
        "checks.maxBuckets": true,
        "checks.metaFields": true,
        "checks.pattern": true,
        "checks.setup": true,
        "checks.template": true,
        "checks.timeFilter": true,
        "configuration.ui_api_editable": true,
        "cron.prefix": "wazuh",
        "cron.statistics.apis": [],
        "cron.statistics.index.creation": "w",
        "cron.statistics.index.name": "statistics",
        "cron.statistics.index.replicas": 0,
        "cron.statistics.index.shards": 1,
        "cron.statistics.interval": "0 */5 * * * *",
        "cron.statistics.status": true,
        "customization.enabled": true,
        "customization.logo.app": "",
        "customization.logo.healthcheck": "",
        "customization.logo.reports": "",
        "customization.reports.footer": "",
        "customization.reports.header": "",
        "enrollment.dns": "192.168.1.142",
        "enrollment.password": "",
        "hideManagerAlerts": false,
        "ip.ignore": [],
        "ip.selector": true,
        "wazuh.updates.disabled": false,
        "pattern": "wazuh-alerts-*",
        "timeout": 20000,
        "reports.csv.maxRows": 10000,
        "wazuh.monitoring.creation": "w",
        "wazuh.monitoring.enabled": true,
        "wazuh.monitoring.frequency": 900,
        "wazuh.monitoring.pattern": "wazuh-monitoring-*",
        "wazuh.monitoring.replicas": 0,
        "wazuh.monitoring.shards": 1,
        "vulnerabilities.pattern": "wazuh-states-vulnerabilities-*"
    }
}
  • Stops referencing or validating the enrollment password configuration by eliminating related code, tests, and constants. Simplifies agent registration flow to rely solely on the existing authentication method.

Issues Resolved

https://github.com/wazuh/internal-devel-requests/issues/2414

Evidence

Verify that the following 3 requests are made in parallel when accessing deploy-agent (/app/endpoints-summary#/agents-preview/deploy).
GET /
GET /cluster/status
GET /groups
image
image
image

Test

  1. Check the evidence.
  2. Follow the steps detailed here (https://documentation.wazuh.com/4.12/user-manual/agent/agent-enrollment/security-options/using-password-authentication.html#prerequisites) and the enrollment should be successful

image

Check List

  • All tests pass
    • yarn test:jest
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

gonzaarancibia and others added 2 commits May 16, 2025 18:42
* feat(endpoints-summary-ui): Add back button to endpoints summary

Signed-off-by: gonzaarancibia <[email protected]>

* fix: apply prettier formatting

Signed-off-by: gonzaarancibia <[email protected]>

* fix: apply prettier formatting to register-agent component

Signed-off-by: gonzaarancibia <[email protected]>

* doc(changelog): Added back button to Deploy Agent page that redirects to Endpoints Summary #7443

Signed-off-by: gonzaarancibia <[email protected]>

---------

Signed-off-by: gonzaarancibia <[email protected]>
Stops referencing or validating the enrollment password configuration by eliminating related code, tests, and constants.
Simplifies agent registration flow to rely solely on the existing authentication method.
@guidomodarelli guidomodarelli self-assigned this May 22, 2025
Refactors asynchronous operations to fetch version, config,
and group data in parallel, reducing wait time and improving
component load performance.
Prevents exposure of agent enrollment credentials in API responses
to enhance security and avoid unauthorized agent registration
by users with read-only API roles.
@guidomodarelli guidomodarelli marked this pull request as ready for review May 22, 2025 19:25
@Machi3mfl Machi3mfl changed the base branch from 4.13.0 to 4.12.2 May 26, 2025 12:22
…l-configuration-information-to-read-only-users
@Machi3mfl Machi3mfl changed the base branch from 4.12.2 to 4.13.0 May 26, 2025 12:23
Copy link
Contributor

Wazuh Core plugin code coverage (Jest) test % values
Statements 47.55% ( 438 / 921 )
Branches 41.09% ( 157 / 382 )
Functions 45.73% ( 150 / 328 )
Lines 47.75% ( 436 / 913 )

Copy link
Contributor

Wazuh Check Updates plugin code coverage (Jest) test % values
Statements 78.72% ( 185 / 235 )
Branches 62.72% ( 69 / 110 )
Functions 61.7% ( 29 / 47 )
Lines 78.72% ( 185 / 235 )

Copy link
Contributor

Main plugin code coverage (Jest) test % values
Statements 16.34% ( 4940 / 30218 )
Branches 10.41% ( 1998 / 19193 )
Functions 17.46% ( 1288 / 7375 )
Lines 16.59% ( 4828 / 29100 )

@guidomodarelli
Copy link
Contributor Author

guidomodarelli commented May 26, 2025

Closed in favor of #7462, as it will be merged in 4.12.2.

@guidomodarelli guidomodarelli deleted the enhancement/2414-restrict-access-to-partial-configuration-information-to-read-only-users branch May 26, 2025 13:04
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.

2 participants