Mitigation Strategy: Strong, Unique Passwords & 2FA
Mitigation Strategy: Enforce strong passwords and require Two-Factor Authentication (2FA) for all administrative accounts.
Description:
- Password Policy (config.php): Modify the
config.php
file to set minimum password length (e.g., 12 characters), require a mix of uppercase, lowercase, numbers, and symbols, and potentially disallow common passwords using a blacklist. This is done using YOURLS's built-in configuration options. - 2FA Plugin Installation: Install a 2FA plugin (e.g., a Google Authenticator plugin) from the YOURLS plugin directory. This utilizes YOURLS's plugin system.
- 2FA Configuration: Configure the 2FA plugin, typically involving setting up a secret key and providing instructions for users to link their authenticator apps. This is done within the YOURLS admin interface.
- 2FA Enforcement: Make 2FA mandatory for all administrative accounts. This usually involves a setting within the 2FA plugin or YOURLS core configuration, accessible through the admin panel.
- User Education: Provide clear instructions to administrators on how to set up and use 2FA (though this is less about YOURLS itself).
Threats Mitigated: * Brute-Force Attacks (Severity: High): * Credential Stuffing (Severity: High): * Unauthorized Account Access (Severity: High): * Phishing (Severity: Medium):
Impact: * Brute-Force Attacks: Risk reduced to near zero. * Credential Stuffing: Risk significantly reduced. * Unauthorized Account Access: Risk significantly reduced. * Phishing: Risk reduced.
Currently Implemented:
* config.php
has a minimum password length of 8 characters and requires numbers.
* A Google Authenticator plugin is installed but not enforced.
Missing Implementation: * Password complexity requirements are not fully enforced. * 2FA is optional, not mandatory. * No blacklist of common passwords.
Mitigation Strategy: IP Restriction (Whitelist)
Mitigation Strategy: Restrict access to the YOURLS admin panel to a specific set of allowed IP addresses.
Description:
- Identify Admin IPs: Determine the static IP addresses (or ranges) from which administrators will access the YOURLS admin panel.
- Configuration (config.php): YOURLS allows specifying allowed IPs directly in the
config.php
file using theYOURLS_ADMIN_IPS
constant. This is the key YOURLS-specific action. - Testing: Thoroughly test.
Threats Mitigated: * Unauthorized Access (Severity: High): * Brute-Force Attacks (Severity: High): * Remote Exploits (Severity: Medium):
Impact: * Unauthorized Access: Risk significantly reduced. * Brute-Force Attacks: Risk significantly reduced. * Remote Exploits: Risk reduced.
Currently Implemented: * No IP restriction is currently in place.
Missing Implementation:
* The YOURLS_ADMIN_IPS
constant needs to be configured in config.php
.
Mitigation Strategy: Limit Login Attempts
Mitigation Strategy: Limit the number of failed login attempts from a single IP address.
Description:
- Plugin or Core Functionality: Utilize either YOURLS's built-in rate limiting (if available) or install a YOURLS plugin that provides this functionality. This relies on YOURLS's plugin system or core features.
- Configuration: Configure the rate limiting settings within YOURLS (either through the plugin's settings page or YOURLS's own configuration options).
Threats Mitigated: * Brute-Force Attacks (Severity: High):
Impact: * Brute-Force Attacks: Risk significantly reduced.
Currently Implemented: * A basic rate-limiting plugin is installed, limiting to 10 attempts per hour.
Missing Implementation: * The lockout period and threshold could be adjusted within the plugin's settings.
Mitigation Strategy: Change Default Admin Path
Mitigation Strategy: Change the default /admin
path to a less predictable URL.
Description:
- config.php Modification: Edit the
config.php
file and change theYOURLS_ADMIN_FOLDER
constant to a new, non-obvious path. This is a direct YOURLS configuration change. - Testing: Access the admin panel using the new path.
Threats Mitigated: * Automated Scanners (Severity: Low): * Opportunistic Attackers (Severity: Low):
Impact: * Automated Scanners & Opportunistic Attackers: Provides a small degree of protection.
Currently Implemented:
* The default /admin
path is still in use.
Missing Implementation:
* The YOURLS_ADMIN_FOLDER
constant needs to be changed in config.php
.
Mitigation Strategy: Strict Input Validation & Sanitization (XSS)
Mitigation Strategy: Rigorously validate and sanitize all user input, both in the YOURLS core and in any installed plugins.
Description:
- Plugin Review: Carefully review the code of all third-party YOURLS plugins before installation. This focuses on the YOURLS plugin ecosystem.
- Custom Code (If Applicable): If you develop custom YOURLS plugins or modifications, implement strict input validation and sanitization within the plugin's PHP code. This is specific to extending YOURLS.
Threats Mitigated: * Cross-Site Scripting (XSS) (Severity: High):
Impact: * XSS: Risk significantly reduced.
Currently Implemented: * YOURLS core appears to have good practices. * One installed plugin has questionable input handling.
Missing Implementation: * The problematic plugin needs review/modification/replacement.
Mitigation Strategy: HTTPOnly and Secure Cookies
Mitigation Strategy: Ensure all cookies are marked as HttpOnly
and Secure
.
Description:
- config.php: YOURLS allows configuring cookie settings in
config.php
. SetYOURLS_COOKIE_HTTPONLY
totrue
andYOURLS_COOKIE_SECURE
totrue
. This is a direct YOURLS configuration.
Threats Mitigated: * Cross-Site Scripting (XSS) (Severity: Medium): * Man-in-the-Middle (MitM) Attacks (Severity: Medium):
Impact: * XSS: Risk of cookie theft via XSS reduced. * MitM Attacks: Risk of cookie interception reduced.
Currently Implemented:
* YOURLS_COOKIE_HTTPONLY
is set to true
.
* YOURLS_COOKIE_SECURE
is set to false
.
Missing Implementation:
* YOURLS_COOKIE_SECURE
needs to be set to true
in config.php
.
Mitigation Strategy: Prepared Statements (SQL Injection)
Mitigation Strategy: Use prepared statements or a robust ORM for all database interactions.
Description:
- Plugin Review: Review the code of all third-party YOURLS plugins to ensure they use prepared statements. This focuses on the YOURLS plugin ecosystem.
- Custom Code (If Applicable): If you write custom YOURLS plugin code that interacts with the database, always use prepared statements.
Threats Mitigated: * SQL Injection (Severity: High):
Impact: * SQL Injection: Risk significantly reduced.
Currently Implemented: * YOURLS core and installed plugins appear to use prepared statements.
Missing Implementation: * No missing implementation identified.
Mitigation Strategy: Validate Redirect Targets (Open Redirects)
Mitigation Strategy: Validate redirect targets to prevent open redirect vulnerabilities.
Description:
- URL Validation (Long URLs): Ensure YOURLS validates that long URLs being shortened are valid URLs (this is a core YOURLS function).
- Prevent Arbitrary Redirects: Ensure YOURLS does not allow arbitrary redirects (this is inherent to YOURLS's core logic).
- Whitelist (If Necessary): If you implement any custom redirection logic within a YOURLS plugin, validate the target URL.
Threats Mitigated: * Open Redirects (Severity: Medium):
Impact: * Open Redirects: Risk significantly reduced.
Currently Implemented: * YOURLS validates long URLs. * No known open redirect vulnerabilities in the core.
Missing Implementation: * No missing implementation identified.
Mitigation Strategy: Rate Limiting (API & Shortening)
Mitigation Strategy: Implement rate limiting on both the API and the URL shortening functionality.
Description:
- YOURLS Plugin: Install a rate-limiting YOURLS plugin that specifically targets the YOURLS API and shortening endpoint. This leverages the YOURLS plugin system.
- Configuration: Configure the rate limiting settings within the YOURLS plugin.
Threats Mitigated: * Denial of Service (DoS) (Severity: Medium):
Impact: * DoS: Risk significantly reduced.
Currently Implemented: * Basic rate limiting is in place for the shortening endpoint (via a plugin). * No rate limiting is in place for the API.
Missing Implementation: * A YOURLS plugin providing API rate limiting needs to be installed and configured.
Mitigation Strategy: Plugin Management
Mitigation Strategy: Keep YOURLS plugins updated, disable unused plugins, and thoroughly vet new plugins.
Description: This entire strategy revolves around managing YOURLS plugins through the YOURLS admin interface.
Threats Mitigated: * Plugin-Specific Vulnerabilities (Severity: Variable):
Impact: * Plugin-Specific Vulnerabilities: Risk significantly reduced.
Currently Implemented: * Plugins are updated sporadically. * Several unused plugins are enabled.
Missing Implementation: * Regular plugin update schedule. * Disable/remove unused plugins. * Rigorous plugin vetting.
Mitigation Strategy: Information Disclosure
Mitigation Strategy: Disable debug mode.
Description:
1. Disable YOURLS_DEBUG
:
* Open config.php
.
* Set YOURLS_DEBUG
to false
. This is direct YOURLS configuration.
Threats Mitigated:
* Information Disclosure (Severity: High):
Impact:
* Information Disclosure: Risk significantly reduced.
Currently Implemented:
* YOURLS_DEBUG
is set to true
.
Missing Implementation:
* YOURLS_DEBUG
must be set to false
in config.php
.