Skip to content
CMO & CTO
CMO & CTO

Closing the Bridge Between Marketing and Technology, By Luis Fernandez

  • Digital Experience
    • Experience Strategy
    • Experience-Driven Commerce
    • Multi-Channel Experience
    • Personalization & Targeting
    • SEO & Performance
    • User Journey & Behavior
  • Marketing Technologies
    • Analytics & Measurement
    • Content Management Systems
    • Customer Data Platforms
    • Digital Asset Management
    • Marketing Automation
    • MarTech Stack & Strategy
    • Technology Buying & ROI
  • Software Engineering
    • Software Engineering
    • Software Architecture
    • General Software
    • Development Practices
    • Productivity & Workflow
    • Code
    • Engineering Management
    • Business of Software
    • Code
    • Digital Transformation
    • Systems Thinking
    • Technical Implementation
  • About
CMO & CTO

Closing the Bridge Between Marketing and Technology, By Luis Fernandez

Input Validation Patterns that Work

Posted on November 5, 2012 By Luis Fernandez

Every nasty breach starts with a tiny text box. The scary part is it often looks like a normal form field you ship every day.

If you build for the web or mobile today, input validation is the fence between a quiet night and a pager at 3 am.

We keep seeing fresh dumps from SQL injection in paste sites, and it is not because attackers found new magic. It is because teams still trust the browser to be a bouncer and forget the server is the actual door. Windows 8 just landed, everyone is pushing new apps and APIs, and the attack surface grows with every shiny feature flag. Client side checks are there for the user and for nice error messages, not for security. The rule that always pays rent is simple and old but easy to skip in the rush to ship: validate input, escape output, and use prepared statements. Toss in sane character encoding rules and you already cut a giant slice off your risk.

The pattern that works in practice is whitelist first and everything else second. Say what a field may contain and be strict about it. A username is letters and numbers with a short length cap, not a playground for punctuation and invisible Unicode. An id is a number and nothing more. Emails look simple but can turn into a regex museum piece, so keep the check basic, trim noise, and confirm with a message later if you really care. Do length limits before deeper checks to stop overlong payloads early. Pick one encoding on input, normalize once, then validate on that canonical form to avoid sneaky bypasses from mixed encodings or double encoding tricks. Good boundary checks beat clever expressions every time.

When data reaches a context, match the defense to that exact context. For databases, prepared statements and parameterized queries kill classic SQL injection and they also make code easier to read than string building. Stored procedures do not save you if you still concatenate strings inside them, so treat them with the same care. In NoSQL injection land, do not pass raw JSON objects from the client to queries, and scrub out operators like dollar ne and friends. For output, encode per sink and per context, which means HTML body, attribute, JavaScript string, CSS, and URL all have different rules, and that is where XSS usually sneaks in. If you can turn on a basic content security policy you get a nice net for missed cases. Keep HttpOnly and Secure on cookies, fail closed with friendly messages, and log rejected inputs with enough detail to spot probes without dumping secrets into logs.

Good validation is boring by design, and that is exactly why it works year after year.

General Software Software Engineering

Post navigation

Previous post
Next post
  • Digital Experience (94)
    • Experience Strategy (19)
    • Experience-Driven Commerce (5)
    • Multi-Channel Experience (9)
    • Personalization & Targeting (21)
    • SEO & Performance (10)
  • Marketing Technologies (92)
    • Analytics & Measurement (14)
    • Content Management Systems (45)
    • Customer Data Platforms (4)
    • Digital Asset Management (8)
    • Marketing Automation (6)
    • MarTech Stack & Strategy (10)
    • Technology Buying & ROI (3)
  • Software Engineering (310)
    • Business of Software (20)
    • Code (30)
    • Development Practices (52)
    • Digital Transformation (21)
    • Engineering Management (25)
    • General Software (82)
    • Productivity & Workflow (30)
    • Software Architecture (85)
    • Technical Implementation (23)
  • 2025 (12)
  • 2024 (8)
  • 2023 (18)
  • 2022 (13)
  • 2021 (3)
  • 2020 (8)
  • 2019 (8)
  • 2018 (23)
  • 2017 (17)
  • 2016 (40)
  • 2015 (37)
  • 2014 (25)
  • 2013 (28)
  • 2012 (24)
  • 2011 (30)
  • 2010 (42)
  • 2009 (25)
  • 2008 (13)
  • 2007 (33)
  • 2006 (26)

Ab Testing Adobe Adobe Analytics Adobe Target AEM agile-methodologies Analytics architecture-patterns CDP CMS coding-practices content-marketing Content Supply Chain Conversion Optimization Core Web Vitals customer-education Customer Data Platform Customer Experience Customer Journey DAM Data Layer Data Unification documentation DXP Individualization java Martech metrics mobile-development Mobile First Multichannel Omnichannel Personalization product-strategy project-management Responsive Design Search Engine Optimization Segmentation seo spring Targeting Tracking user-experience User Journey web-development

©2025 CMO & CTO | WordPress Theme by SuperbThemes