Feat wasm verification#48
Merged
Merged
Conversation
…ect code style refs
- Dockerfile.dev: add WABT 1.0.41 (wasm2c, wasm2wat), wasi-sdk-33.0,
lld-16, libc6-dev. Fix GPG key for apt.llvm.org.
- modules/frontend/wasm_lifter.{cpp,hpp}: new WasmLifter module that
lifts .wasm → LLVM IR via wasm2c + clang-16 pipeline
- modules/frontend/CMakeLists.txt: integrate WasmLifter OBJECT library
- modules/backend/pass/OverflowPass.cpp: fix 3 null pointer dereference
bugs (calleeFunction nullptr, DbgDeclareInst nullptr) causing segfault
on ControlFlow benchmarks
- test-comp2026/simulation: add run_controlflow_inside.sh and
run_controlflow_coverage_inside.sh for TestComp 2026 ControlFlow
- docs/migration/1.7-wasm-pipeline.md: document WASM pipeline phases,
sessions, and risks
- docs/{map2check_migration_plan,PLAN}.md: update progress and WASM plan
…seg-paper - Add book-to-skill converter skill for generating book/document skills - Add map2check-sbseg2026: unified skill merging paper knowledge + project mgmt - Core frameworks, 6 chapters, glossary (43 terms), patterns (8), cheatsheet - Submission context, backlog, CTA checklist, consolidated data, figure inventory - WASM pipeline status and implementation plan - Remove sbseg-paper (merged into map2check-sbseg2026) - Add wasm-implementation-plan.md with full roadmap (sub-etapas 1.7.3-1.7.7) - Update SKILL.md with WASM status, backlog items, topic index entries
- Sec 1: add usage example (listing), fill all citations, compare with competitors - Sec 2: add competitor comparison at each checkpoint (CPAchecker, Symbiotic, FuSeBMC, ESBMC) - Sec 3: replace passes table with paragraph focused on techniques, remove isRequired() detail - Sec 3: remove fig3 (passes) and fig5 (CI/CD), add OpenSSF reference - Sec 4: rename to 'Análise Experimental', remove fig4 (pizza chart), merge bugs into results paragraph - Sec 4: remove bugs table, fix CWE mapping (valid-deref → CWE-416, add valid-memsafety) - Sec 5 (Demonstração): removed entirely per advisor - Sec 6: split into isolated 'Conclusão' - Add 4 bib entries: cwe2025, fioraldi2020aflpp, chalupa2021symbiotic, openssf2024 - All 23 citations filled, 0 empty
- ch01: rewritten with usage example, filled references, competitor framework comparison - ch02: rewritten with competitor comparison at each TACAS checkpoint - ch03: rewritten with techniques-focused passes paragraph, OpenSSF, no isRequired() detail - ch04: rewritten as 'Análise Experimental', CWE mapping fixed, bugs merged, WASM more precise - ch05: removed (Demonstração removida do paper) - ch06: rewritten as isolated 'Conclusão' - SKILL.md: updated section count (6→5), chapter index, figure inventory (5→2 figs) - glossary: +7 new terms (CPAchecker, Z3, CWE-190, Smart Seeds, wasi-sdk, Program Slicing, Portfólio de Solver) - Updated via pandoc conversion: LaTeX → Markdown → book-to-skill extractor → Mode 4 fold-in
WASM pipeline end-to-end proven: .wasm → wasm2c → LLVM IR → passes → KLEE 250M KLEE instructions executed on lifted WASM code Changes: - map2check: --wasm flag + --entry-function flag, accept .wasm extension - map2check: WasmLifter integration before Caller construction - caller: generateWasmWrapperStatic() creates main() → wasm bridge - caller: refactored linkLLVM() to include WasmRuntimeStubs before witness link - caller: pass --entry-function and --wasm-mode to opt - Map2CheckLibrary: EntryFunction cl::opt replaces hardcoded "main" - MemoryTrackPass: MemTrackEntryFunction cl::opt + WasmMode flag - MemoryTrackPass: instrumentWasmBoundsCheck() injects bounds check on wasm memory loads/stores - WasmRuntimeStubs.c: malloc-based wasm-rt stubs for KLEE compatibility - wasm_lifter: fixed entry point detection for w2c_*_0x5Fstart pattern - CMakeLists.txt: WasmRuntimeStubs.bc compilation with WABT include path - cmake/FindZ3.cmake: fixed library search paths - Skill: updated WASM pipeline status (all components ✅) Approach B (bounds-only): CWE-119/787 coverage, full tracking deferred to post-SBSeg.
Add detailed analysis of why wasm2c static array model prevents memory safety detection (CWE-401 leak, CWE-416 UAF, CWE-415 double-free) via Map2Check's current malloc/free-based MemoryTrackPass. Includes: - Technical explanation of wasm2c memory model (u8 wasm_memory[]) - Impact table by SV-COMP property - Three mitigation strategies (A/B/C) with difficulty assessment - SBSeg MVP recommendation: focus on overflow + reachability - Empirical validation checklist for next session
Key insight: intercepting w2c_*_dlmalloc by name only works for C→WASM, not for arbitrary .wasm files from Rust, Go, AssemblyScript. Changes: - Add 'Distinção Crítica' section: C→WASM known vs arbitrary WASM - Add 'O que é linguagem-agnóstico' table: common wasm2c elements - Add 'O que é viável para o MVP' diagram: bounds + overflow + reach - Rewrite 'Estratégias' as short/medium/long term horizons - Update 'Checklist B.4' for bounds checking across languages - Update 'Riscos' table with language-allocator risk - Update 'Recomendação MVP' for language-agnostic priorities
- main.tex: ControlFlow coverage-error-call results (138 tasks, score 38) - main.tex: Juliet WASM validation (6 cases, pipeline confirmed end-to-end) - .gitignore: add juliet/ clone directory - juliet_wasm/wasm_results.csv: pipeline results for all 6 WASM cases - compile_juliet_wasm.sh: script to compile C subset to WASM Pipeline validated: WASM -> wasm2c -> LLVM IR -> Map2Check -> KLEE. All 6 cases processed, confirming architectural gap: static wasm2c arrays are invisible to MemoryTrackPass.
…ackPass - main.tex: replace 6 mixed cases with 15 real Juliet cases (CWE-121 to 127) - main.tex: document linear memory bounds gap with research conclusions - MemoryTrackPass.cpp: bounds checking returns early (wasm2c provides native bounds via wasm_rt_trap -> map2check_error already) - MemoryTrackPass.hpp: add WasmModeActive member for pass constructor - wasm_results_v2.csv: 15/15 cases pipeline functional, UNKNOWN expected Key finding: per-buffer overflow cannot be detected at linear memory level (wasm2c checks 0 to mem->size, not per-allocation bounds). Full memory safety requires allocator-aware instrumentation (Fase 2, post-SBSeg).
Implements bounds checking by intercepting wasm2c allocator functions (w2c_*_dlmalloc/w2c_*_dlfree) in MemoryTrackPass and verifying every load/store against registered allocations. Changes: - MemoryTrackPass.hpp: add instrumentWasmMalloc/Free, isWasmAllocator/ isWasmDeallocator helpers, 3 new FunctionCallee members - MemoryTrackPass.cpp: intercept dlmalloc/dlfree by name pattern, register offsets+size in AllocationLog, verify load/store offsets - AnalysisModeMemtrack.c: add map2check_wasm_malloc/free/check_access - Map2CheckFunctions.h: declare new WASM runtime functions - main.tex: update results (3/3 heap FALSE, 12 stack UNKNOWN) Results: 3/3 Juliet heap overflow cases (CWE-122, CWE-126) detected as FALSE with OVERFLOW property violation. Stack cases (CWE-121/124/127) require allocator-independent tracking (Fase 2, post-SBSeg).
- main.tex: remove --- (use continuous prose), add entrypoint details to WASM section (generateWasmWrapperStatic, w2c_*_start translation) - main.tex: update conclusion with WASM results - tests/integration/test_wasm_pipeline.sh: heap overflow detection, safe heap access, CLI --wasm flag validation - tests/integration/test_wasm_entrypoint.sh: _start entrypoint extraction, special chars in module names, WASI imports
- ci.yml: install wabt via apt, symlink wasm-rt.h to /opt/wabt/include - CMakeLists.txt (WasmRuntimeStubs): try /opt/wabt-1.0.41, /opt/wabt, then /usr/include - caller.cpp: check multiple paths for wasm-rt.h include (use stat()) - map2check.cpp: same fallback for WasmLifter wasmRtIncludePath - Add #include <sys/stat.h> for stat() fallback logic
- SKILL.md: mark WASM items 4-8 completed, add ControlFlow results, update WASM pipeline data (bounds, Juliet, CLI, CI), add 4 new frameworks (dlmalloc interception, entrypoint translation, per-allocation bounds, linear memory gap), expand topic index - PLAN.md: update all section progress (avg 90%), mark WASM 1.7.1-1.7.7 completed, set overall progress to 85%, add Iteracao 4 (2026-07-04) - 1.7-wasm-pipeline.md: set status to Fase 1.7 concluded - glossary.md: +7 terms (wasm2c, linear memory, dlmalloc, entrypoint translation, per-allocation bounds, WasmRuntimeStubs) - patterns.md: +3 patterns (WASM Lifting, dlmalloc Interception, Entrypoint Translation) - cheatsheet.md: +2 tables (WASM Pipeline Quick Reference, Propriedades Detectaveis no WASM, CI Debug)
- Add e2e-wasm job to GitHub Actions (build + run integration tests inside Docker) - Install WABT/wasi-sdk in CI and symlink KLEE runtime/compiler-rt files - Add MAP2CHECK_DYNAMIC_LINK CMake option for shared-library builds - Restore WasmRuntimeStubs as default build target when wasm-rt.h is present - Fix entrypoint regex in test_wasm_entrypoint.sh for hex-encoded names - Update Juliet compile script to 15 CWE-121/122/124/126/127 cases - Add wasm_results_v2.csv: 15/15 FALSE with 290s timeout - Update skill and migration docs with actual WASM status
…pipeline - Update WASM Juliet section: 15/15 FALSE (was 3 FALSE + 12 UNKNOWN) - Add WAsmCases/WasmFalse/WasmTimeout macros - Add fig6-wasm-pipeline.mmd diagram - Add nsa2017juliet reference to bibliography - Add video storyboard for SBSeg SF (5-7 min) - Update wasm_results.csv with 15 Juliet cases - Update README with modernized build instructions - Update migration docs with completed statuses
…EADME
- Replace PNG figures with TikZ (vector, scalable, larger font)
- fig1-timeline.tikz.tex: timeline 2016-2026 with stagnation gap
- fig2-pipeline.tikz.tex: 5-stage verification pipeline in Docker
- Update main.tex to use \input{img/figX-tikz.tex}
- Update img/README with rendering instructions for fig6-wasm-pipeline.mmd
apt ubuntu-22.04 has wabt 1.0.27 whose wasm-rt.h lacks: - wasm_rt_funcref_table_t (added after 1.0.27) - bool parameter in wasm_rt_allocate_memory This caused WasmRuntimeStubs.c compilation failure in CI. Fix: download WABT 1.0.41 tarball in all 3 CI jobs (build-and-test, static-analysis, sanitizer-tests) instead of 'apt install wabt'.
…ccess The map2check-dev image uses non-root user 'map2check' which cannot write to /opt to install wasi-sdk. Use -u root.
- main.tex: KLEEVersion 3.x -> 3.1 - SKILL.md, patterns.md, cheatsheet.md, chapters/ch03, ch04 - migration docs (1.4, 1.4.3) - figures (.mmd, .tikz.tex) - video scripts - README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pipeline WASM end-to-end validado: o Map2Check agora verifica binários
.wasmdiretamente viamap2check --wasm, reaproveitando todo o pipeline LLVM 16 + KLEE existente. 15 casos da Juliet Test Suite (CWE-121/122/124/126/127) foram validados com 15/15 FALSE. Infraestrutura de CI completa com jobs de build, testes unitários, análise estática, sanitizers e novo job E2E com KLEE real em container Docker.Motivation
O pipeline WASM estava implementado mas não validado empiricamente. Os resultados eram inconsistentes entre execuções locais e CI devido a 4 problemas críticos de infraestrutura:
wasm-rt.hdo apt não temwasm_rt_funcref_table_tnembool is64— WasmRuntimeStubs.c quebravaCMAKE_FIND_LIBRARY_SUFFIXES=".a"impedia o build com KLEE em ambientes com Z3/STP apenas como bibliotecas compartilhadasninja installnão copiavaklee-uclibc.bcanem compiler-rt, causando crash do KLEE no E2EType of change
How Has This Been Tested?
build-and-test,static-analysis,sanitizer-testspassando (build limpo com clang-16, sem warnings novos)e2e-wasm: build em container Docker com KLEE real, executatest_wasm_pipeline.sh(3/3) +test_wasm_entrypoint.sh(3/3)map2check --wasm --memtrack --timeout 290, 15/15 FALSEctest --output-on-failure)Para reproduzir localmente:
Changes
Pipeline WASM (modules/frontend/, modules/backend/)
Build System (CMakeLists.txt, modules/backend/library/lib/CMakeLists.txt)
CI (.github/workflows/ci.yml)
Testes (tests/integration/)
Benchmarks Juliet WASM (test-comp2026/simulation/)
Documentação
Checklist