Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Slack Engineering 5 min read Announcement mediumAdept

Hakana: Taking Hack Seriously

Slack has open-sourced Hakana, a Rust-based type checker and static analyzer for Hack, built on Psalm's design and reusing the Hack parser bundled with HHVM. Slack runs it in CI to catch unused code, impossible or redundant type checks, misuse of internal APIs, and security flaws. Security checks use interprocedural taint analysis similar to Facebook's internal Zoncolan, plus a literal-string type that blocks SQL injection at function boundaries. Plugin hooks support custom type inference and fast codebase-wide migrations, and on Slack's roughly 5 million lines it runs about 5x faster than Psalm and on par with the official Hack typechecker.

Assumes: PHP or Hack basicsstatic type checking

Related posts

  • Hacklang at Slack: A Better PHP

    Slack Engineering mediumAdept

    Slack moved its PHP 5 backend to HHVM in 2016 for speed and stayed for Hack, whose static type checker reports type errors as code is typed rather than at runtime. Gradual typing let the team migrate incrementally from partial to strict mode. Shapes, typed dicts with known and optional keys, are used for database rows, decoded JSON and functions with many options. Async/await with concurrent blocks adds I/O concurrency without threads, while dropping PHP compatibility in HHVM 4.0 improved the language at the cost of the Packagist ecosystem and constant upgrade work.

  • How Two Interns Are Helping Secure Millions of Lines of Code

    Slack Engineering mediumAdept

    Slack added Hack support to Semgrep so its 5+ million lines of Hack could be scanned for security vulnerabilities, since no static analysis tools exist for the language. The work had two parts. First, a Tree-sitter grammar for Hack was extended incrementally, guided by error counts on internal repos, cutting unparsable lines from over 120,000 to 15 (a parse rate above 99.999%). Second, an OCaml parser maps the Tree-sitter CST onto Semgrep's language-agnostic AST, and the grammar was extended to recognize Semgrep pattern syntax such as ellipses. The resulting rules check for OWASP Top Ten issues on every pre-deploy change and in a daily full-codebase scan.

  • Auditing in the age of (good enough) AI

    Trail of Bits hardMaster

    Before auditing the Miden zero-knowledge VM, Trail of Bits spent six months using Claude and Codex agents to build tooling for its custom stack-based assembly language (MASM): an LSP server, a decompiler with a reusable IR, an abstract-interpretation static analysis engine, and a Lean model of the VM executor. The analyses flagged 400+ locations with missing type validation and a high-severity bug where an unvalidated prover-supplied remainder in mod_12289 would let a malicious prover forge Falcon signatures and drain accounts. Agents also produced 95 machine-checked Lean correctness proofs covering the core library's binary arithmetic, uncovering edge-case bugs in rotr and wrapping_mul. The broader point is that capable agents make exploratory, hard-to-justify tooling projects cheap enough to pursue routinely.

  • Protecting user data through source code analysis at scale

    Meta Engineering mediumAdept

    Meta's Anti-Scraping team encodes known scraping attack vectors as taint-analysis rules in its in-house static analyzers, Zoncolan for Hack and Pysa for Python, so potential vectors are flagged before code ships. Rules define sources (user-controlled parameters such as a result count or target ID) and sinks (data returned to the user), and a possible flow between them is raised as an issue for triage. In a mock followers endpoint, an uncapped count lets scrapers pull entire follower lists in one request and slip past rate limiting. The fix clamps count to a maximum, forcing scrapers into many more requests that rate limits then catch. Static analysis cannot catch scrapers that mimic legitimate usage, so it is one part of a broader defense.

  • More Than 2x Faster Hashing in ClickHouse Using Rust

    ClickHouse mediumAdept

    ClickHouse added optional Rust library support to its C++/CMake build using Corrosion-rs, with BLAKE3 as the first library, exposed to C++ through a Rust shim function using C-compatible FFI types and a header file. BLAKE3 hashes more than 2x faster than SHA224/SHA256 and slightly faster than MD5, while staying secure and resistant to length extension. Perf flamegraphs show the shim's type conversion costs about 1.15% of query time. Integration hurdles included MemorySanitizer false positives on Rust memory, fixed with __msan_unpoison and explicit byte conversion, plus cross-platform linking, with aarch64-darwin still unsupported. The integration also had to stay optional, statically linked, cross-compilable and compatible with sanitizers.

The quest for software engineering knowledge.

Look:
Layout: