Saltar al contenido ForoHackers

Secure coding: start here

Programación segura
#3319 · · Citar · Denunciar

Secure coding is writing programs so that mistakes are less likely to become vulnerabilities. It is not a separate phase but a set of habits in design, naming, error handling and review. Most security bugs repeat a short list of patterns, so learning those patterns and the safe alternative to each pays off in every language.

Key concepts

  • Validate at the boundary: check type, length, range and format of every outside input, and reject rather than repair.
  • Safe by construction: parameterised queries, memory-safe languages and escaping libraries make the safe way the easy way.
  • Fail safely: on error, deny access, release resources and avoid leaking internal details in messages.
  • Secrets: never hard-code them, never log them, load them from the environment or a vault.
  • Review and tooling: code review with a security lens, plus linters, analysers and tests for abuse cases.

Vocabulary

  • Injection: untrusted data interpreted as code or commands.
  • Race condition: a result that depends on the timing of concurrent actions, sometimes a security flaw.
  • Allow-list: accepting only known-good values, rather than blocking known-bad ones.
  • Technical debt: shortcuts whose cost returns later, often as incidents.

What to study, in order

  1. The common weakness lists, with a short example and the safe version of each.
  2. Rewrite a small program that builds queries or commands by string joining, so that it uses parameters.
  3. Add input validation and clear error handling to a project of your own, with tests for hostile input.
  4. Learn the safe parts and the dangerous parts of your language's standard library.
  5. Turn on compiler warnings, a linter and a security-focused analyser in your build, and fix what they report.

Related tags

#appsec #code-review #static-analysis #testing #rust

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder