Summary
An arbitrary file write vulnerability in the 3X-UI web control panel allows an authenticated administrator to abuse the database import feature to overwrite files on the host via manipulated Xray configuration values.
When Xray is running with elevated privileges, this condition can be used to obtain code execution and persistent access as the Xray process user, potentially including root.
Affected context
The issue arises in deployments using the 3X-UI web control panel to manage Xray-core servers where database import functionality is available to administrative users.
Risk is present when Xray configuration values stored in the database are applied directly to the filesystem without robust validation or path controls.
Impact increases significantly in environments where Xray runs with high privileges or has write access to sensitive application or system directories.
Exploit preconditions
- Attack surface: 3X-UI web interface, specifically the database import functionality
- Required access: Authenticated administrator or any role capable of triggering database imports and modifying Xray configuration values
- Trigger point: Importing a crafted database snapshot or configuration set that results in unsafe file writes when Xray configuration is applied
- Why exploitation is possible: File paths and configuration-derived write locations are taken from database content without sufficient validation, allowing attacker-controlled paths or content to be written to arbitrary locations on the host
Why this happens
The root cause is insecure handling of filesystem paths and write operations derived from configuration data stored in the database.
3X-UI trusts configuration values imported from the database and uses them to drive file writes for Xray without enforcing strict path constraints, whitelisting, or isolation.
This corresponds to CWE-73: External Control of File Name or Path, where external inputs control the location and nature of file operations, enabling attackers to target arbitrary files for overwrite or creation.
Potential impact
- Arbitrary file creation or overwrite on the host accessible to the Xray process
- Introduction of malicious configuration or script files leading to code execution
- Persistent backdoors via modified startup scripts or service definitions
- Escalation of privileges when Xray runs as root or has access to system directories
- Disruption of service or denial of service by corrupting critical configuration or application files
General mitigation guidance
Effective mitigation focuses on constraining how configuration data influences filesystem operations and reducing trust in imported database content.
Recommended patterns include:
- Enforcing strict whitelists of allowed configuration-controlled file paths and directories
- Normalizing and validating all paths before performing file writes, rejecting relative or traversal constructs
- Segregating configuration-generated files into dedicated, non-privileged directories with limited impact if compromised
- Running Xray and associated management components with least-privilege service accounts instead of root
- Implementing defense-in-depth checks so that database import routines validate configuration shape and reject unexpected file-related entries
How teams detect issues like this
Detection typically combines code-level review and runtime monitoring:
- Static analysis or manual review to identify file operations whose paths are derived from database or configuration inputs without robust validation
- Audit of the database import workflow to ensure no unbounded mapping from imported values to filesystem locations
- Logging and monitoring of configuration changes and database imports, with alerts for unusual path values or writes to non-standard directories
- Policy-based checks in CI/CD or pre-deployment reviews requiring explicit justification for configuration-driven file writes and verifying path constraints

