Black Friday Deals For Authors Are On Now!

Leanpub Header

Skip to main content

Application & API Security

Bought separately

$145

Minimum price

$49.00

$69.00

You pay

Author earns

$

Also available for 2 book credits with a Reader Membership

These books have a total suggested price of $145. Get them now for only $49.00!
About

About

About the Bundle

Books

About the Books

API Security in Practice

API Security in Practice

A hands-on field guide to securing the HTTP, GraphQL, and event-driven APIs that modern platforms run on. The book is organised as a security programme rather than a product catalogue, and every chapter pairs runnable configuration and code with the pitfalls that cause real breaches, a prioritised remediation order, and a hands-on exercise.

You will start by building an inventory that survives reality and mapping it to the OWASP API Security Top 10 (2023), then threat-model APIs with Schemathesis property-based tests and Open Policy Agent policies. The core technical body covers OAuth 2.1 and OpenID Connect with PKCE, client credentials and step-up authentication; JWT validation done correctly (algorithm pinning, audience binding, JWKS rotation, denylists); API keys and mutual TLS; and authorization — scopes, roles, and the object-, property-, and function-level checks that fix API1, API3 and API5, with OPA/Rego and Envoy ext_authz examples.

The abuse-control block covers JSON Schema validation at the gateway, injection classes that survive naive validation, GraphQL depth, amount, alias and batching attacks, rate limiting and quotas, replay protection with idempotency keys and RFC 9421 message signatures, webhook verification with secret rotation, and securing Kafka event-driven APIs against unsafe consumption.

The operational block covers secrets management with dynamic credentials and envelope encryption, OpenTelemetry-based security logging and detections, abuse detection with JA3/JA4 fingerprints, CI/CD and supply-chain integrity (cosign, SLSA, pin by commit SHA), zero-trust API architecture, and an API incident response playbook. A capstone chapter assembles Keycloak, Kong, Envoy, OPA and an instrumented service into a working stack with end-to-end security tests and a production-readiness checklist.

Secure API Implementation

Secure API Implementation

Most "secure" APIs fail because the fix for broken authorization requires a decision at every call site, and decisions that aren't encoded and tested as code don't survive deadlines. This book takes that structural view of API security and works through the full defensive stack, one layer per chapter, with runnable Python and TypeScript code, policy examples, and worked request traces.

You'll start with threat modeling: how to map the OWASP API Top 10 (2023) onto your own surface, run a 90-minute threat model, walk STRIDE against a concrete request flow, and turn findings into testable mitigations that live in your test suite.

From there the book covers transport security (TLS configuration, HSTS and preload, internal mTLS, automatable baseline checks), authentication with OAuth 2.1 and OIDC (authorization code with PKCE, client credentials, device grant, opaque vs JWT, correct JWT validation, sender-constrained tokens via DPoP and mTLS, key rotation without downtime), and phishing-resistant authentication with passkeys and WebAuthn — including a TypeScript relying party, conditional mediation, account recovery, and a migration path away from passwords.

Authorization gets its own deep treatment: object-level checks via query-scoped lookups, function-level permission matrices, property-level input binding, returning 404 instead of 403, and route × role matrix tests. Also covered: input validation and injection defense (including SSRF and uploads), secrets management with Vault dynamic database credentials and Kubernetes-native patterns, data classification, logging, caching and privacy, rate limiting and quotas (token bucket in Redis, edge limiting, bulkheads, cost-based quotas), and abuse prevention including credential stuffing and bot detection.

Later chapters cover service-to-service identity (mTLS, SPIFFE, ReBAC, the confused deputy problem, least-privilege database access), observability and detection engineering, security testing (Semgrep, OpenAPI contract tests, ZAP, fuzzing, CI), supply-chain integrity (SBOM, Sigstore, SLSA provenance), deployment hardening for containers, Kubernetes and cloud, incident response playbooks for leaked credentials, compromised tokens, mass BOLA exploitation and SSRF, governance with ASVS and SAMM, and a full walkthrough building a production-grade "Ledger" API.

SAST and DAST Implementation

SAST and DAST Implementation

## About the Book

This is a working guide to shipping static application security testing (SAST) and dynamic application security testing (DAST) inside a real DevSecOps pipeline — not a survey of what the tools do.

It opens with the premise that a scanner is not a program: findings do not become risk on their own. From there you build an application risk model, map threat scenarios to trust boundaries and data flows, and use that model to decide what to scan and what to ignore.

The middle chapters cover the mechanics. **Ch. 2** covers SAST architecture, rule authoring, and data-flow analysis, with SonarQube security hotspots as the worked example. **Ch. 3** covers DAST architecture, crawlers, and session handling, with the OWASP ZAP proxy and active-scan flow shown step by step. **Ch. 4** widens the surface to APIs, GraphQL, single-page apps, mobile, infrastructure as code, dependencies, and containers — including SBOM generation with Dependency-Track.

**Ch. 5** is where findings become work: severity mapping, suppression files, deduplication, and triage. **Ch. 6** moves the tools into the developer loop — IDE plugins, pre-commit hooks, GitHub Actions pull-request and nightly DAST workflows, and GitLab CI. **Ch. 7** covers feedback design, metrics, governance, and executive reporting. **Ch. 8** is a remediation pattern catalog. **Ch. 9** and **Ch. 10** are end-to-end walkthroughs: one building a secure pipeline, one validating it against OWASP Juice Shop.

Every chapter carries runnable code — roughly twenty Python utilities (risk scoring, SARIF fingerprinting, cross-instance grouping, CODEOWNERS routing, a SARIF collector, a diff gate, a scope guard, a DAST auth assertion, a GraphQL check, a BOLA harness, CSRF HMAC tokens, path-traversal containment, Argon2id hashing) and a set of Bash scripts, plus YAML for Semgrep, Checkov, Trivy, CodeQL, and ZAP Automation Framework plans. The book closes with a 30/60/90-day operational roadmap and a readiness checklist.

## Who This Is For

Application security engineers, DevSecOps engineers, and security leads who need to stand up or repair SAST and DAST in CI. Also useful for platform engineers wiring quality gates into existing pipelines, and for developers who want to understand why a gate blocked their pull request.

Security DevOps in Practice

Security DevOps in Practice

Security DevOps in Practice is a hands-on guide to embedding security into software delivery without turning it into a release blocker. It assumes you already work with Linux, networking, containers, CI/CD, and cloud infrastructure, and adds the security layer across all of it as concrete configuration and code rather than general advice.

You will start by building a shared-responsibility and risk model — who owns identity, cluster, and application controls, and how to turn that into a prioritized backlog instead of a wish list. From there you threat model with data flow diagrams and STRIDE, then write security requirements that become enforceable policy. The tooling chapters cover CODEOWNERS, secret elimination with gitleaks and cloud secret managers, dependency locking with Dependabot and lockfiles, SAST (Semgrep), IaC scanning (tfsec, Checkov, Trivy), container scanning, supply-chain scoring, and DAST — with baselines, severity gates, and triage workflows.

The middle of the book covers SBOM generation in CycloneDX and SPDX, provenance attestations, cosign and KMS signing, and policy as code with OPA Rego and unit-tested admission policies. Chapter 6 hardens CI/CD itself: scoped `permissions:`, script-injection prevention, `gh actions-lock` lockfiles over SHA pinning, safe `pull_request_target` and `workflow_run` patterns, runner isolation, and secret handling. Later chapters cover cloud and Kubernetes defense in depth (identity, posture, network, workload protection with Kyverno and Falco), observability and Sigma-based detection, incident response runbooks and rollback, platform guardrails and golden paths, and governance metrics. The final chapter threads it all together: a Python API with Postgres, built in Docker, deployed to Kubernetes via Terraform and GitHub Actions, with simulated attacks, policy rejections, and a rollback.

Every chapter includes pitfalls, false-positive traps, hands-on exercises, knowledge checks, and a recap checklist you can paste into your backlog.

Prompt Injection Attack and Defense

Prompt Injection Attack and Defense

This is a hands-on engineering guide to securing LLM applications against prompt injection, written for developers who already call a model API and need a defensible design method rather than a primer on tokens.

The book starts by reframing the problem: an LLM application is not a model plus a prompt, but a context assembler, tool layer, output renderer, and permission system. Injection exploits the seams between them. You will threat-model your own app, map findings to OWASP LLM01:2025 and MITRE ATLAS (AML.T0051, AML.T0051.001, AML.T0054), and work through documented incidents including EmailGPT (CVE-2024-5184), the GitHub MCP exploit, EchoLeak, Amazon Q, and the Promptware case study.

Attack chapters cover direct injection, indirect injection, jailbreaks and the instruction hierarchy, RAG retrieval poisoning and provenance filters, tool abuse and the MCP surface, multimodal payloads, and exfiltration. Defense chapters cover detection with measured false-positive rates, layered mitigations, least-privilege tool design with per-user identity, sandboxing, output validation gateways, consent-integrity approval gates, runtime monitoring, and architectural patterns such as dual-LLM and CaMeL-style separation.

The operational third covers red-team automation with promptfoo, PyRIT, garak, and Inspect AI; continuous evaluation in CI; deployment hardening; incident response runbooks; and a complete end-to-end secure support assistant in layered Python modules.

Every chapter ends with a recap checklist and a runnable exercise. The book separates documented evidence, vendor-reported measurements, and its own expert recommendations, and cites CVEs, papers, and advisories with identifiers.

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub