Skip to content

Archive

Secure Coding

64 articles
Cybersecurity 06 Sep 2026 11 min read

Bound Work Before Processing Untrusted Input

An input does not need to be malicious code to hurt a service. It only needs to make the service spend far more memory, CPU time, storage, or concurrency than the sender spent creating the request. A parser may accept deeply nested data. A compressed upload may expand far beyond its transfer size. A search endpoint may allow a query that is valid but unusually expensive. If enough work begins before the application applies a limit, a small amount of incoming traffic can consume resources needed by legitimate users.

Cybersecurity 05 Sep 2026 10 min read

Prevent Log Injection with Structured Events

Security logs are useful only when their meaning survives the journey from an application to the people and systems that read them. If untrusted text can change where one event appears to end, create convincing fake fields, or confuse a downstream parser, an attacker may be able to make suspicious activity harder to interpret. This problem is commonly called log injection or log forging. It happens when data controlled by an external party is treated as part of the log format rather than as data inside a log event.

Cybersecurity 05 Sep 2026 10 min read

Make Sensitive Operations Safe to Retry

A client sends a request to create a refund. The server completes the refund, but the response is lost when the connection closes. The client cannot tell whether the operation succeeded, so it retries. If the server treats the retry as a new operation, one uncertain network failure can become two refunds. The same pattern appears in credit transfers, invitation acceptance, provisioning, job submission, and other state-changing actions where repeating an effect has security or financial consequences.

Cybersecurity 05 Sep 2026 9 min read

Keep Untrusted Paths Inside an Intended Directory

Applications often need to turn input into a file operation: download a report, store an attachment, load a template, or unpack an archive. A dangerous mistake is treating an input path as if it were only a name. Paths contain structure, and that structure can redirect the operation somewhere the application did not intend. If an application expects a file under one directory but lets untrusted input influence the resolved location, a path traversal flaw can expose or overwrite files outside that directory. The consequence depends on what the process can access: configuration, application data, credentials, or other users’ files may fall within reach.

Cybersecurity 05 Sep 2026 11 min read

Do Not Trust the Request Host for Security-Sensitive URLs

Applications sometimes need to create an absolute URL. A password-reset email, email-verification message, or security notification may need a link such as https://accounts.example.com/reset/... rather than a relative path. A tempting implementation takes the host name from the current HTTP request and combines it with the path. That is convenient, but it can quietly move a security decision into attacker-controlled input. If the deployment accepts an unexpected host value, the application may generate a valid security token inside a link pointing at the wrong site.

Cybersecurity 04 Sep 2026 9 min read

Treat Deserialization as a Trust Boundary

Applications constantly turn bytes into useful values. A request body becomes a set of fields, a cached value becomes a record, or a message from a queue becomes a command. This conversion is called deserialization when the bytes represent a previously encoded data structure. The security problem begins when deserialization does more than recover inert data. Some serialization systems can reconstruct application-specific object types or trigger behavior while rebuilding an object graph. If an attacker can influence that serialized input, the parser may be asked to create types or invoke mechanisms that the application never intended to expose at that boundary.

Cybersecurity 04 Sep 2026 11 min read

Rotate Session Identifiers After Authentication

A web application often creates a session before a user signs in. The session may hold a shopping cart, a language preference, or state needed during an authentication flow. After login, it is tempting to keep the same session identifier and simply mark that session as authenticated. That creates a security problem if someone else already knows or influenced the pre-login identifier. Authentication has increased what the session is allowed to do, but the credential used to refer to that session has not changed. A previously low-value identifier may suddenly become a key to an authenticated account.

Cybersecurity 04 Sep 2026 10 min read

Reduce Account Enumeration with Consistent Authentication Responses

A login form can reject every incorrect password and still reveal useful information about its users. If the application says Account not found for one email address and Wrong password for another, anyone who can submit login attempts can learn which address belongs to an account. That information leak is called account enumeration. The same problem can appear in password-reset, registration, invitation, and account-recovery flows. Even when the visible message is identical, differences in HTTP responses, redirects, response size, or processing time can reveal the same fact.

Cybersecurity 04 Sep 2026 10 min read

Normalize Security-Sensitive Input Before Making Decisions

Security checks often compare names, paths, identifiers, hosts, or other values against a rule. The rule may be correct and the comparison may look correct, yet the system can still make the wrong decision if different components interpret the same input differently. For example, one layer may treat two textual forms as equivalent while another treats them as different. A validator can approve one representation, then a later component can normalize or decode it into a different value before using it. The security check and the operation are no longer reasoning about the same thing.

Cybersecurity 04 Sep 2026 10 min read

Keep Redirect Targets Inside Trusted Destinations

Redirects are useful after sign-in, checkout, account setup, and many other workflows. The danger appears when an application lets request data decide the destination without enforcing where that destination may point. For example, a sign-in page might accept a next value and redirect the user there after authentication. If any absolute URL is accepted, an attacker can create a link on the application’s real domain that sends the user to an unrelated site. The first URL looks legitimate, but the final destination is controlled by someone else.

Cybersecurity 04 Sep 2026 9 min read

Keep Internal Error Details Out of Client Responses

When an application fails, developers need enough detail to diagnose the problem. The client usually does not. If the same exception text, stack trace, database error, filesystem path, or upstream response is sent to both places, an ordinary failure can become an information leak. The consequence is not that every leaked error immediately compromises a system. The problem is that internal details can reveal data, identifiers, software structure, trust relationships, or assumptions that were never meant to cross the application’s public boundary. They can also expose secrets when sensitive values have been included in an exception or diagnostic message.

Cybersecurity 04 Sep 2026 11 min read

Keep File Access Inside an Intended Directory

Applications often let a caller identify a file: download an invoice, open an exported report, read a template, or retrieve an uploaded document. The dangerous version of this design treats a caller-controlled path as if it were already a permitted file. A path can describe movement through a filesystem, not just a filename. If untrusted input is combined with an application directory without a reliable containment check, the resulting path may resolve somewhere outside that directory. A read operation can expose configuration or private data; a write or delete operation can have more serious consequences.

Cybersecurity 04 Sep 2026 9 min read

Keep Data Separate from Interpreter Syntax

Applications constantly move data into systems that interpret syntax: databases parse queries, shells parse commands, browsers parse HTML, and template engines parse expressions. A security problem appears when data that should remain inert can change the structure of those instructions. That is the core of injection. If an attacker can influence where instructions end and data begins, the receiving interpreter may perform work the developer never intended. The consequence depends on the interpreter: unauthorized database operations, unintended operating-system actions, or active content in a browser are all possible outcomes of the same design mistake.

Cybersecurity 04 Sep 2026 9 min read

Allowlist Writable Fields to Prevent Mass Assignment

An API endpoint may look harmless because it updates only the current user’s profile. The danger can appear one layer lower: if the framework automatically copies every supplied request field into the stored user object, the client may be able to change properties that the interface never intended to expose. For example, a profile request might legitimately accept display_name and timezone. The underlying user record may also contain role, account_status, or billing_limit. If the update path treats every recognized object property as client-writable, authorization decisions made elsewhere can be bypassed through an ordinary update operation.

Cybersecurity 03 Sep 2026 10 min read

Validate Untrusted Input at Trust Boundaries

Applications constantly receive data they did not create: HTTP parameters, uploaded metadata, webhook payloads, queue messages, imported files, configuration from external systems, and values read from shared storage. The security problem is not that every external value is malicious. The problem is that application code can make unsafe assumptions about values whose shape, size, meaning, or origin has not been established. Boundary validation reduces that risk by checking untrusted data before the rest of the application relies on it. The goal is simple: turn vague external input into explicit internal invariants.

Cybersecurity 03 Sep 2026 9 min read

Enforce Object-Level Authorization on Every Request

An application can authenticate a user correctly and still expose another user’s data. The failure often happens when an endpoint accepts a resource identifier, loads that resource, and assumes that knowing the identifier is enough to use it. It is not. A resource ID answers which object the client wants. Authorization must separately answer whether this actor may perform this action on that object. This article develops a practical mental model for object-level authorization, shows where checks belong, and explains how to avoid common gaps when applications grow beyond simple owner-only data.