Dev.to Security 🔐 Cybersecurity 👁 0 📖 4 min read

Zero-Egress Jira Compliance PDFs in a Forge Web Worker (and 3 Bugs Unit Tests Missed)

When security teams ask for Jira change-management evidence during a SOC 2 or ISO 27001 audit, most PDF export tools work the same way: pull issues via OAuth to an external server, render HTML with headless Chrome, and h

When security teams ask for Jira change-management evidence during a SOC 2 or ISO 27001 audit, most PDF export tools work the same way: pull issues via OAuth to an external server, render HTML with headless Chrome, and hand back a download link.

That architecture fails vendor review fast. Sending raw Jira issue descriptions, comments, and attachments to a third-party rendering server is the exact data-egress risk auditors ask about.

While building AuditPack — a compliance evidence exporter currently in Atlassian Marketplace review — I wanted it to qualify for Atlassian's Runs on Atlassian program with zero external egress. No external.fetch permissions in manifest.yml, only three scopes (read:jira-work, read:jira-user, storage:app), and all PII redaction, AICPA sampling, PDF rendering, ZIP streaming, and SHA-256 manifest hashing running inside a browser Web Worker.

The core pipeline came together quickly. What actually broke — and took the most work to harden — were three things that looked fine in unit tests and only surfaced under live Jira Cloud traffic and mutation testing.

1. Live Jira Cloud's /changelog/bulkfetch Returned Numeric Epoch Timestamps

To avoid N+1 requests when pulling approval histories for hundreds of issues, we used Jira Cloud's POST /rest/api/3/changelog/bulkfetch endpoint (up to 1,000 issue keys per call).

Every unit and integration test passed against our local fake Jira server, where changelog created fields were standard ISO-8601 strings ("2026-11-26T10:00:00.000Z").

The first time we ran an export against a real Jira Cloud site with 153 seeded issues, the worker blew up immediately:

TypeError: a.created.localeCompare is not a function

Unlike the per-issue changelog endpoint, Jira Cloud's /rest/api/3/changelog/bulkfetch returned created as a numeric epoch millisecond (e.g. 1764160000000) instead of an ISO string.

The fix was a small normalizer at the Jira client boundary — and, more importantly, updating our fake Jira test server to emit numeric epoch-ms from /changelog/bulkfetch so the test double actually matches production wire format:

function normalizeJiraTimestamp(raw: unknown): string {
  if (typeof raw === "number" && Number.isFinite(raw)) {
    return new Date(raw).toISOString();
  }
  if (typeof raw === "string") {
    const trimmed = raw.trim();
    if (/^\d{10,15}$/.test(trimmed)) {
      return new Date(Number(trimmed)).toISOString();
    }
    return trimmed;
  }
  return "";
}

Lesson learned: mock servers drift from vendor APIs in subtle type ways. Always run at least one end-to-end export against a real tenant with seeded edge-case issues before trusting a green suite.

2. Offline Unicode / CJK PDFs Inside a Zero-Egress Web Worker

Without an external headless browser, PDF generation happens in-worker via pdf-lib + @pdf-lib/fontkit.

That immediately hits two walls in real Jira tickets:

  1. pdf-lib's built-in StandardFonts only support WinAnsi. Any Korean/CJK character, emoji (🚨, ✅), or even smart punctuation (—, •) either throws an encoding error or renders tofu boxes.
  2. You cannot fetch Google Fonts at runtime without breaking zero-egress.

We solved this by bundling OFL-licensed NanumGothic-Regular.ttf and NanumGothic-Bold.ttf (~2 MB each) directly as static assets inside the Forge resource bundle, then running every string through a deterministic sanitizer before layout:

  • Map common incident emojis (🚨 -> [ALERT], ✅ -> [OK], ⚠️ -> [WARN]) and remaining astral surrogate pairs to [EMOJI] so font subsetting never crashes on color-emoji glyphs.
  • Strip zero-width joiners, variation selectors (U+FE0E/U+FE0F), and non-newline control characters.
  • If a caller ever falls back to WinAnsi (without a loaded TTF), map typographic punctuation (— -> --, • -> -, curly quotes -> ASCII) before escaping any remaining non-Latin-1 code points as [U+XXXX].

Every exported PDF also gets inspected offline with Poppler (pdftotext + pdfinfo) in our QA script to verify zero mojibake and readable Korean/Latin text extraction.

3. 95% Line Coverage Still Left a 60.46% Mutation Score

Our Vitest suite hit 95.07% statement / line coverage across the core modules:

  • PII/ePHI & secret redaction (API keys, JWTs, PEM blocks, SSNs, phone numbers, Luhn-verified credit cards)
  • Deterministic AICPA sampling (FNV-1a seed hash + Mulberry32 PRNG + 100% emergency/hotfix stratification)
  • Separation of Duties (SoD) checks
  • OWASP CSV formula neutralization
  • Streaming ZIP + SHA-256 manifest generation (verify.sh / verify.ps1)

Out of curiosity — and because compliance evidence bugs are silent — we ran StrykerJS mutation testing across those five modules.

The first run scored 60.46%. Nearly 40% of mutated code still passed every test.

A few concrete gaps the surviving mutants uncovered:

  • Luhn & regex boundary slop: Off-by-one length bounds (13 vs 12, 19 vs 20) and lookbehind guards preventing SSN regexes from accidentally chewing up ISO dates (2026-11-26) were not tightly pinned by negative test cases.
  • CSV formula neutralization edges: Leading =, +, -, @ were tested, but whitespace/tab-prefixed formula cells and embedded quotes had surviving mutants.
  • Deterministic sampling reproducibility: Mutating the FNV-1a seed constant or Fisher-Yates swap index didn't fail enough assertions until we pinned exact expected sample outputs for fixed seeds plus 100% hotfix inclusion invariants.

After adding a focused mutation-hardening suite, StrykerJS climbed from 60.46% to 94.9% (744/784 mutants killed, 0 no-coverage).

Takeaway

Building inside Atlassian Forge's zero-egress sandbox forces cleaner architecture than I expected — once you accept doing PDF rendering, redaction, and ZIP hashing in a Web Worker, you eliminate an entire class of backend infrastructure and customer security-review friction.

If you're building on Forge or working with Jira Cloud REST API v3, two quick tips:

  1. Normalize timestamps defensively on /changelog/bulkfetch (don't assume ISO strings).
  2. Run StrykerJS at least once on any redaction, CSV escaping, or sampling code — high line coverage is surprisingly easy to fool.

If you try AuditPack once it clears Atlassian Marketplace review and hit any edge case with your Jira setup, let me know — our team monitors issues closely and ships fixes within 12 hours.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.