At SquareBoat, we take mobile and web security seriously. Though we do understand that security is a never-ending pursuit and no matter how many doors you lock, you'll still leave a few open, we would like to do our best to ensure that.
- Only use UNIX-based operating systems for all day to day operations, which includes MacOS and Linux. Other OS's are permitted but for testing purposes only.
- User a strong laptop password which is difficult to guess or brute-force.
- Enable disk encryption so that others cannot unplug your hard disk and copy your data
- No passwords stored in plain text anywhere. Use tools like Dashlane for all passwords, including personal accounts
- Enable 2FA for all supported accounts, including email accounts etc.
- Use of strong Wifi passwords (with WPA2 encryption) which are difficult to brute-force.
- Non trusted machines can connect but only via guest networks
- Turn off your Wifi router when not in use.
- Disable SSID broadcast
- No password logins on any server. Only SSH keys.
- Default SSH port should be changed from 22 to some other port.
- Direct SSH (even with a valid key) is not allowed. SSH access is only permitted via a jumphost.
- fail2ban is enabled to detect multiple failed SSH attempts
- All ports except port 80 are closed.
- SSL always - No product will be ever launched with an http:// URL.
- Always use the latest version of Apache, PHP etc. when starting off a new project and upgrade periodically.
- Disable directory listing
- Use Blade or any other templating engine to prevent XSS attacks.
- CSRF tokens are a must for all form submissions and AJAX requests.
- Admin login page and user login pages must be separate. The admin login page must have a captcha.
- Send an email to the user whenever his password has changed
- Uploaded files must be scanned for virused and malware
- Prevent or restrict the uploading of any file that may be interpreted by the web server.
- Validate uploaded files are the expected type by checking file headers. Checking for file type by extension alone is not sufficient.
- Validate your redirects - Do not allow the user to supply (parts of) the URL to be redirected to.
- Validate data on both frontend and backend
- Always hash and save passwords, ideally using bcrypt and a salt
- Temporary passwords and links should have a short expiration time. Enforce the changing of temporary passwords on the next use.
- Log all authentication attempts, especially the failed attempts
- Do not log passwords in log files
- Turn off execution privileges on file upload directories
- Cookies must be httponly
- Never connect to the database with the root user
- Throttle all API's, especially ones that can be brute forced
- Require to enter a CAPTCHA after a number of failed logins from a certain IP address
- Users must enter their password if they are updating their primary email or phone number which they are using for logging in.
- When sanitizing, protecting or verifying something, prefer whitelists over blacklists.
- Never upload user files in a directory which can be directly accessed by Apache. Always store them one level below it.
- Never construct SQL queries manually. Always use ORM tools.
- Never store any passwords in version control.
- Force minimum password length rules for atleast 6 characters, if not more.
- Re-authenticate users prior to performing critical operations. Example: Delete your account
- For very high value accounts, use MFA (Multi-factor authentication)
- If long authenticated sessions are allowed, periodically revalidate a user’s authorization to ensure that their privileges have not changed and if they have, log the user out and force them to re-authenticate. The application must support disabling of accounts and terminating sessions when authorization ceases.
- Disable debug mode on production servers
- Testing servers should always be behind HTTP auth
- Users having admin right must use a secure password. The application should not allow weak passwords for admins (Minimum 10 characters, mix of lowercase, uppercase and digits)
- Disable autocomplete on form fields expected to contain sensitive information (Example: Secret answers, PAN number etc.)
- Never display code errors on production
- Set common security headers like Content Security Policy, X-Frame-Options, X-XSS-Protection etc.
-
Content-Security-Policy: The new Content-Security-Policy HTTP response header helps you reduce XSS risks on modern browsers by declaring what dynamic resources are allowed to load via a HTTP Header
-
X-Frame-Options: 'SAMEORIGIN' - allow framing on same domain. Set it to 'DENY' to deny framing at all or 'ALLOWALL' if you want to allow framing for all website. Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites
-
X-XSS-Protection: Largely unnecessary in modern browsers when sites implement a strong Content-Security-Policy.
-
X-Content-Type-Options: 'nosniff' by default - stops the browser from guessing the MIME type of a file.
-
Access-Control-Allow-Origin: Used to control which sites are allowed to bypass same origin policies and send cross-origin requests.
-
Strict-Transport-Security: Used to control if the browser is allowed to only access a site over a secure connection. Example: Strict-Transport-Security: max-age=31536000; includeSubDomains (All present and future subdomains will be HTTPS for a max-age of 1 year. This blocks access to pages or sub domains that can only be served over HTTP.)
Further reading: https://www.owasp.org/images/0/08/OWASP_SCP_Quick_Reference_Guide_v2.pdf