Start a project

Let’s build something that works

The first conversation is free, you’ll leave with clarity, not a sales pitch.

or email hello@zentury.studio

We’ll only use your details to reply to you. See our Privacy Policy.

HomeInsightsTechnology

App Security Best Practices: A Practical Guide for Web and Mobile

Practical app security best practices for web and mobile products, from authentication and encryption to API security, testing and incident response, in one checklist.

Zentury team10 min read
Developer reviewing a security checklist and padlock icon on a laptop screen

The most effective app security practices are the unglamorous ones: verify who is calling, check what they may do, protect data wherever it travels or rests, and keep secrets and dependencies under control. Consistent fundamentals beat exotic tooling.

This guide walks through the practices that matter for web and mobile products, from authentication to incident response, with a risk table you can use as a checklist.

The short answer

Security works in layers, and no single control covers everything. Build these into the product from the start.

  • Prove identity properly with strong authentication and well-managed sessions.
  • Check permissions on the server for every request.
  • Encrypt data in transit and at rest.
  • Keep secrets out of code and rotate them.
  • Treat all input as untrusted and validate it on the server.
  • Keep dependencies current and know what you ship.
  • Log what matters, test regularly and rehearse your response to incidents.

Common risks at a glance

Risk What it means How to reduce it
Broken authentication Accounts are taken over through weak passwords, stolen credentials or poor sessions Multi-factor authentication, rate limiting, secure session tokens
Broken authorisation Users reach data or actions that belong to someone else Server-side checks on every request, deny by default
Injection Untrusted input is run as a command or query Parameterised queries, validation, output encoding
Data exposure Data is readable in transit, in storage or in logs TLS everywhere, encryption at rest, careful logging
Exposed secrets Keys or passwords sit in code, builds or chats Secrets manager, rotation, repository scanning
Vulnerable dependencies A third-party package contains a known flaw Routine updates, audits, pinned versions
Insecure APIs Endpoints accept too much, return too much or lack limits Authentication, schema validation, rate limits
Insecure mobile storage Tokens or personal data sit unprotected on the device Platform secure storage, minimal local data
Weak monitoring Attacks go unnoticed until damage is done Central logs, alerts, a tested response plan

Authentication and sessions

Authentication answers one question: is this person who they claim to be? Get it wrong and every other control becomes easier to bypass.

Strengthen sign-in

Offer multi-factor authentication and make it the default for sensitive products. Store passwords only as salted hashes made with a purpose-built algorithm such as Argon2, bcrypt or scrypt. Rate limit login attempts to slow credential stuffing, where attackers reuse passwords leaked elsewhere. Where possible, use an established identity provider or well-maintained library rather than writing your own login system.

Manage sessions carefully

A stolen session is as good as a stolen password. Use long, random tokens, and set cookies with the Secure, HttpOnly and SameSite attributes. Expire idle sessions, rotate the token after login and privilege changes, and invalidate it on logout and password reset. Let users see and end sessions on other devices.

Authorisation and access control

Authorisation decides what a signed-in user may do, and the server must enforce it on every request. Hiding a button in the interface does not stop someone calling the endpoint directly.

The most common flaw is the insecure direct object reference: a user changes an identifier in a request and receives another customer’s record, because the server only checked that they were logged in. Always confirm the user has rights to the specific resource requested.

  • Deny by default. Access is refused unless a rule grants it.
  • Least privilege. Give users, services and staff only the access their job requires.
  • Centralise checks. Keep permission logic in one place so it is consistent and easy to review.

Encrypting data in transit and at rest

Encrypt data whenever it moves and whenever it is stored. These are separate problems with separate controls.

In transit

Serve every page and API over HTTPS with current TLS versions, redirect plain HTTP and enable HTTP Strict Transport Security. In mobile apps, never disable certificate validation to make a test environment work. Encrypt traffic between your own services as well, not only between the user and your edge.

At rest

Encrypt databases, file storage and backups, and protect the keys separately from the data. For especially sensitive fields, consider field-level encryption so a database leak alone does not expose them. Collect only the data you need, because data you never store cannot be stolen. Regulated products carry extra duties, covered in our guides to GDPR compliance for apps and HIPAA-compliant app development.

Secrets management

API keys, database passwords and signing keys should never live in source code, a mobile app bundle or a shared document. Once a secret reaches a repository, assume it is compromised, because history preserves it even after deletion.

  • Store secrets in a dedicated secrets manager or protected environment configuration.
  • Give each environment its own credentials, so a development leak cannot open production.
  • Rotate keys on a schedule and immediately after any suspected exposure.
  • Scope each key narrowly to its purpose.
  • Run secret scanning on repositories and in the build pipeline.

Anything shipped inside a mobile app or front-end bundle can be extracted. Keep sensitive keys on the server and have the app call your backend instead.

Input validation and common web risks

Treat every input as untrusted, whether it comes from a form, URL, header, file upload or another system. Validate on the server, because client-side checks only help honest users. Prefer allow-lists of what is acceptable over block-lists, and check type, length, format and range.

  • Injection: use parameterised queries or a trustworthy ORM, and never build queries by joining strings.
  • Cross-site scripting (XSS): encode output for its context, use a framework that escapes by default and add a Content Security Policy as a second layer.
  • Cross-site request forgery (CSRF): use SameSite cookies and anti-forgery tokens for state-changing requests.
  • Server-side request forgery (SSRF): restrict which addresses your server may fetch when a user supplies a URL.

Modern frameworks remove much of this risk, but only if used as intended. Bypassing built-in protections for convenience is where problems usually begin. Our web app development work treats these defaults as a baseline.

API security

Many mobile and single-page apps are thin layers over an API, which makes the API the real attack surface. Require authentication on every endpoint that is not deliberately public, and check authorisation per object, not just per route.

Validate request bodies against a schema and reject unexpected fields, which prevents mass assignment, where a user sets properties they should not control. Return only the fields a client needs, since over-sharing responses leak data even when the interface hides it. Apply rate limits to slow abuse and scraping, use short-lived access tokens and keep an inventory of endpoints so old versions are not left running unprotected. For design and integration detail, see our API development and integration guide.

Dependency and supply-chain hygiene

Modern apps are mostly third-party code, so a flaw in a package becomes a flaw in your product. Supply-chain attacks go further, targeting the packages, build tools or accounts that deliver that code.

  • Know what you ship. Keep a lock file or software bill of materials with exact versions.
  • Update routinely. Use automated tools to flag vulnerable packages, then test and apply fixes promptly.
  • Vet new packages. Check maintenance activity and ownership, and ask whether you need the package at all.
  • Protect the pipeline. Use multi-factor authentication on source control and package accounts, limit who can publish and keep build credentials short-lived.
  • Watch for lookalikes. Install from trusted registries and check package names carefully.

Mobile-specific storage and tampering

A mobile app runs on a device you do not control, so assume a motivated attacker can inspect it. The goal is to limit what is stored and make misuse harder, not to pretend the app is unbreakable.

Store tokens and credentials in platform secure storage, the Keychain on iOS and the Keystore on Android, never in plain preferences, local files or logs. Keep local data to a minimum and clear it at logout. Against tampering, obfuscate code, detect rooted or jailbroken devices where the risk justifies it and use platform integrity checks to confirm requests come from a genuine build. Treat these as friction, not guarantees, because a modified client can send any request and the server must validate everything. Our mobile application development work builds on this assumption.

Logging and monitoring

You cannot respond to what you cannot see. Log security-relevant events such as logins, failed attempts, password changes, permission denials, administrative actions and unusual API activity, with a timestamp, account, action and source.

Equally important is what you leave out. Never write passwords, tokens or full card details to logs. Send logs to a central, access-controlled system so an attacker who compromises one server cannot erase the evidence. Then set alerts for patterns that suggest abuse, such as repeated failed logins or sudden request spikes, and decide in advance who receives each alert and what they should do.

Testing: reviews, scans and penetration tests

Different checks catch different problems, so combine them.

  • Code review: a second pair of eyes on every change, with a checklist covering authentication, permissions and input handling.
  • Static analysis: tools scan source code for risky patterns during development.
  • Dependency and secret scanning: run on every build.
  • Dynamic testing: tools probe a running app for issues such as injection and misconfiguration.
  • Penetration testing: skilled testers attempt to break in as an attacker would, finding chained weaknesses automated tools miss.

Run automated checks continuously and schedule penetration tests around major releases or architectural changes. Fix findings by priority, record the decision when you accept a risk and retest after fixes.

Incident response

Every system eventually has an incident, so prepare before it happens. A short written plan prevents confusion when time matters.

  1. Roles: who leads, who communicates and who makes technical decisions.
  2. Detection and triage: how an issue is reported, confirmed and rated.
  3. Containment: how to revoke tokens, rotate secrets, disable accounts or take a feature offline.
  4. Recovery: how to restore from clean backups and confirm the cause is closed.
  5. Notification: legal and contractual duties to inform users or regulators, which vary by region and industry.
  6. Review: a blameless write-up that turns lessons into changes.

Rehearse the plan with a tabletop exercise and confirm that backups actually restore.

Secure development habits

Tools help, but daily habits make security routine.

  • Threat model new features by asking what could go wrong and who might abuse them.
  • Keep environments separate and avoid real customer data in development.
  • Require reviews and protected branches so no change reaches production unchecked.
  • Use secure defaults in shared components, so the safe path is the easy one.
  • Remove unused features, accounts and old endpoints.
  • Treat security issues as normal work items with owners and deadlines.

Where to start

Begin with a review of authentication, authorisation and secrets, then add dependency scanning and logging, and schedule an independent test. If you would like help assessing or building a secure product, contact our team.

Frequently asked questions

01What is the most important app security practice?

There is no single answer, but correct authorisation and strong authentication prevent many of the most damaging problems. If users reach only what they should and attackers cannot easily take over accounts, many other weaknesses become harder to exploit.

02How often should an app be penetration tested?

Test before launch, after major changes and on a regular schedule suited to your risk. Products handling sensitive or regulated data warrant more frequent testing. Run automated scanning continuously in between.

03Is HTTPS enough to secure my app?

No. HTTPS protects data moving between the user and your server, but it does nothing about weak passwords, missing permission checks, injection flaws or exposed secrets. It is one necessary layer among several.

04Are mobile apps less secure than web apps?

They face different risks rather than greater ones. Mobile apps run on devices you do not control, so local storage and tampering matter more. Web apps face browser attacks such as XSS and CSRF. Both depend on a well-protected backend.

05How do I keep third-party packages safe?

Keep a lock file, scan for known vulnerabilities on every build and update promptly. Add new packages only when needed, check that they are maintained and secure the accounts and pipeline that publish your releases.

06Where should API keys be stored?

On the server, in a secrets manager or protected environment configuration. Never place sensitive keys in source code, front-end bundles or mobile apps, because those can be extracted. Rotate keys regularly and scope each to a narrow purpose.

07What should I do if I suspect a breach?

Follow your incident response plan: revoke affected tokens and credentials, preserve logs, assess what data was involved and meet any notification duties. Then recover from clean sources and review what allowed it.

Work with us

Have a project in mind? Let’s talk it through.

Tell us what you’re building. The first conversation is free, and you’ll leave with a clear next step.

Start your project

Keep reading

All insights

09 · Get in touch

Let’s build

Let’s Build Something That Works

Have an idea you’re ready to move on? A problem your current technology isn’t solving? Our team is based in Austin, Texas, and works with businesses all over the world. Reach out: the first conversation is free, and you’ll leave with clarity, not a sales pitch.

Email us
Studio
5900 Balcones Drive STE 100, Austin, Texas 78731

Tell us about your project

We’ll only use your details to reply to you. See our Privacy Policy.