The Contao backend at /contao is the single most attacked surface on any Contao installation. Automated scanners constantly probe for it because the path is predictable and the login form accepts unlimited guesses unless you configure otherwise. On shared hosting this matters beyond the obvious takeover risk: each failed login spins up a PHP worker, hits the database to validate the username, and consumes a slice of the CPU and entry-process limits enforced by CloudLinux. A sustained login flood can exhaust your account's resources and trigger throttling, taking the whole site offline even if no password is ever guessed correctly.

The root cause is almost always a combination of three weaknesses: a backend reachable by anyone on the internet, accounts protected only by a password, and no rate limiting in front of the login endpoint. Contao ships with solid building blocks to fix each of these, including a built-in account lockout, native two-factor authentication, and configurable password rules. What it cannot do is protect the request before PHP boots, so the strongest setups pair Contao's own controls with LiteSpeed-level .htaccess rules. Everything below is achievable from cPanel Jupiter, DirectAdmin Evolution, the Contao backend, and the File Manager without any root or SSH access.

Configure Contao's built-in lockout and password policy

Contao enforces a login lockout per account by default, but the thresholds are worth tightening. Log in to the backend, open the user record under System > Back End Users, and confirm each administrator uses a unique account rather than a shared one. Shared logins make lockout useless because an attacker locking out "admin" also locks out your real staff. For the lockout window itself, Contao reads the security.lock_period setting, which defaults to 300 seconds after too many failures. On a managed configuration you adjust application behavior through the local configuration file rather than any server file you are banned from touching.

Using the File Manager, navigate to your Contao document root and open config/config.yaml (on Contao 5) or the equivalent .env.local and config directory. Keep edits within your own account scope only. A practical hardening block looks like this:

contao:
    security:
        two_factor:
            enforce_backend: true

framework:
    # longer lockout slows automated attacks
    # value in seconds after repeated failures

The password policy lives in the backend under System > Settings. Set the minimum password length to at least 12 characters and avoid reusing any value already seen in a public breach. Contao hashes passwords with the modern PHP password API, so the stored values are safe, but a short password still falls to an offline guess if a backup ever leaks. When you change the minimum length, existing weak passwords are not retroactively rejected, so force a reset by editing each backend user and clearing their current password so they must set a new one on next login.

Disable any unused backend accounts immediately. Every disabled account removes one valid username an attacker can target. In the back end users list, set stale accounts to disabled rather than deleting them if you need an audit trail, and remove the admin flag from anyone who does not genuinely administer the whole system.

Enforce two-factor authentication for every backend user

Two-factor authentication is the control that defeats credential stuffing outright, because a stolen password alone no longer grants access. Contao includes native TOTP-based 2FA compatible with authenticator apps such as Google Authenticator, Authy, or any RFC 6238 client. Each user enables it individually from their own profile: after logging in, they open the account settings via the gear icon, scroll to the Two-factor authentication panel, scan the QR code, and confirm with a generated code. Contao then issues backup recovery codes, which users should store in a password manager rather than on the server.

Relying on voluntary adoption is a mistake. Enforce it globally with the enforce_backend: true setting shown above, which forces any backend user without 2FA to configure it before they can reach the dashboard. After enabling enforcement, log out and test with a non-admin account to confirm the setup wall appears. If a user is ever locked out because they lost their device, you can clear their 2FA secret directly in the database. Open phpMyAdmin from cPanel or DirectAdmin, select your Contao database, open the tl_user table, find the row by username, and set the useTwoFactor field to 0 and clear the secret field. The user will be prompted to re-enrol on their next login because enforcement is still active.

Keep the server clock accurate as well. TOTP codes depend on time synchronization, and a drifting clock causes valid codes to be rejected. You cannot run NTP yourself on shared hosting, but if users report consistent "invalid code" errors despite correct input, open a support ticket so the clock can be checked at the host level rather than assuming the 2FA setup is broken.

Add .htaccess rate limiting and path restrictions

Contao's lockout only triggers after PHP has already processed the request, so a determined flood still burns resources. Shield the login endpoint earlier with .htaccess rules that LiteSpeed reads directly. Place a dedicated .htaccess file in the public contao directory if your routing exposes it, or add scoped rules in the document-root .htaccess. To restrict the backend to known office or VPN IP addresses, use:

<If "%{REQUEST_URI} =~ m#^/contao#">
    Require ip 203.0.113.10
    Require ip 198.51.100.0/24
</If>

If your team works from dynamic IPs and whitelisting is impractical, add an HTTP Basic Auth gate in front of the login so bots never reach the Contao form at all. Create the credential file with cPanel's Directory Privacy tool (or DirectAdmin's Password Protect Directories), which generates a hashed .htpasswd outside the web root, then protect only the backend path:

<If "%{REQUEST_URI} =~ m#^/contao#">
    AuthType Basic
    AuthName "Restricted"
    AuthUserFile "/home/user/.htpasswds/contao/passwd"
    Require valid-user
</If>

This double prompt means an attacker must defeat Basic Auth, the password, and 2FA in sequence. Also block direct access to sensitive files that scanners request constantly, such as the environment file and version control metadata:

<FilesMatch "^(\.env|\.env\.local|composer\.json|composer\.lock)$">
    Require all denied
</FilesMatch>
RedirectMatch 404 /\.git

After deploying these rules, watch the account error log to confirm legitimate logins succeed and attacks are being rejected. In cPanel open Errors or read the error_log file in your document root through the File Manager; repeated 401 and 403 entries against /contao confirm the gate is working. Monitoring this log weekly turns login hardening from a one-time task into an ongoing signal of whether your Contao site remains a quiet target or an actively probed one.