blint 3.3.0__tar.gz → 3.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {blint-3.3.0 → blint-3.4.0}/PKG-INFO +2 -2
- {blint-3.3.0 → blint-3.4.0}/blint/data/rules.yml +18 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/analysis.py +1 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/binary.py +150 -3
- {blint-3.3.0 → blint-3.4.0}/blint/lib/checks.py +14 -0
- {blint-3.3.0 → blint-3.4.0}/pyproject.toml +2 -2
- {blint-3.3.0 → blint-3.4.0}/LICENSE +0 -0
- {blint-3.3.0 → blint-3.4.0}/README.md +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/__init__.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/cli.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/config.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/cyclonedx/README.md +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/cyclonedx/__init__.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/cyclonedx/spdx.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/cyclonedx/spec.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/__init__.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/android-services.json +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/__init__.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_apple_local_privesc_mie.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_drivers_win.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_entries_generic.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_entries_pe.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_exe_go.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_functions_generic.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_implants_pe.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_imports_pe.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_ios_fingerprint.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_ios_masvs.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_ios_privacy_access.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_ios_privacy_posture.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_ios_sidechannel.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_methods_android.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_methods_generic.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_methods_mips.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_methods_pe.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_monero_generic.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_monero_go.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_monero_rust.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_rootkits_win.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_rpc_win.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_symbols_antiforensic.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_symbols_generic.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_symbols_hooka.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_symbols_macho.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/annotations/review_symbols_rust.yml +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/data/trackers.json +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/db.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/__init__.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/android.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/android_services.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/binary_reviews.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/callgraph/__init__.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/callgraph/algorithms.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/callgraph/api.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/callgraph/canon.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/callgraph/command.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/callgraph/fingerprint.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/callgraph/match.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/callgraph/model.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/callgraph/rusi.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/callgraph_kpi.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/crypto_constants.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/dalvik.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/dalvik_callgraph.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/dalvik_cfg.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/dalvik_dataflow.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/dalvik_review.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/dalvik_semantics.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/disassembler.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/driver_ioctl.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/elf_abi.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/elf_dlopen.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/elf_linkmap.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/function_reviews.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/implant_reviews.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/import_attribution.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/indicators.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/ios.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/macho_objc.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/review_runner.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/review_utils.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/runners.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/sbom.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/stack_strings.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/lib/utils.py +0 -0
- {blint-3.3.0 → blint-3.4.0}/blint/logger.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: blint
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Linter and SBOM generator for binary files.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -40,7 +40,7 @@ Requires-Dist: pytest (>=9.0.3) ; extra == "dev"
|
|
|
40
40
|
Requires-Dist: pytest-cov (>=7.1.0) ; extra == "dev"
|
|
41
41
|
Requires-Dist: rich (>=15.0.0)
|
|
42
42
|
Requires-Dist: ruff (>=0.14.0) ; extra == "dev"
|
|
43
|
-
Requires-Dist: wasm-tools (>=2.
|
|
43
|
+
Requires-Dist: wasm-tools (>=2.1.0)
|
|
44
44
|
Project-URL: CI, https://github.com/owasp-dep-scan/blint/actions
|
|
45
45
|
Description-Content-Type: text/markdown
|
|
46
46
|
|
|
@@ -20,6 +20,24 @@
|
|
|
20
20
|
- dotnetbinary
|
|
21
21
|
- MachO
|
|
22
22
|
- mips-executable
|
|
23
|
+
- id: CHECK_WX_SEGMENTS
|
|
24
|
+
title: Writable and Executable Memory Segment
|
|
25
|
+
description: |
|
|
26
|
+
A loadable segment or section is mapped so that the same pages can be both written and executed. This breaks the Write XOR Execute (W^X) invariant: any memory-write primitive — a buffer overflow, a use-after-free, an unsafe deserialization routine — becomes direct code execution, because the pages the processor runs are the pages an attacker can modify.
|
|
27
|
+
Such mappings usually come from the link or pack step rather than the source: a single RWX `PT_LOAD` in firmware and binaries processed by older packer releases, a linker script or `-z execstack` build marking every loadable segment read-write-execute, or PE sections carrying `MEM_WRITE` together with `MEM_EXECUTE` after processing by some packers and legacy linkers.
|
|
28
|
+
Keep code segments read-only and executable (`R+X`) and data segments writable and non-executable (`R+W`). Runtime code generation and self-modifying code should write through a private writable mapping and only flip the executable view readable-executable for the duration of the update (`mprotect`/`VirtualProtect`), or use the JIT write-protection support provided by the runtime. `readelf -l` shows the offending segment as `LOAD ... RWE`; `objdump -h` and `dumpbin /headers` show the offending PE sections.
|
|
29
|
+
Beyond exploit mitigation, keeping data non-executable matters for correctness on ARM: non-executable permission is the only mechanism that prevents speculative instruction fetches to a region, so executable data or MMIO mappings can be speculatively fetched by mispredicted indirect branches with unpredictable results on some SoCs.
|
|
30
|
+
severity: critical
|
|
31
|
+
exe_types:
|
|
32
|
+
- genericbinary
|
|
33
|
+
- x86_64-executable
|
|
34
|
+
- x86_64-exec
|
|
35
|
+
- gobinary
|
|
36
|
+
- PE32
|
|
37
|
+
- PE64
|
|
38
|
+
- dotnetbinary
|
|
39
|
+
- MachO
|
|
40
|
+
- mips-executable
|
|
23
41
|
- id: CHECK_PIE
|
|
24
42
|
title: Missing Position-Independent Executable (PIE) Protection
|
|
25
43
|
description: |
|
|
@@ -337,6 +337,118 @@ def parse_relro(parsed_obj: lief.ELF.Binary) -> str:
|
|
|
337
337
|
return "full" if bind_now or now else "partial"
|
|
338
338
|
|
|
339
339
|
|
|
340
|
+
def _rwx_permissions_str(readable: bool, writable: bool, executable: bool) -> str:
|
|
341
|
+
"""Renders segment permissions in the customary ``rwx`` notation."""
|
|
342
|
+
return f"{'r' if readable else ''}{'w' if writable else ''}{'x' if executable else ''}"
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def parse_elf_wx_segments(parsed_obj: lief.ELF.Binary) -> list[dict]:
|
|
346
|
+
"""Collects the loadable ELF segments mapped both writable and executable.
|
|
347
|
+
|
|
348
|
+
The GNU stack is deliberately excluded: an executable ``PT_GNU_STACK`` is
|
|
349
|
+
already reported as a missing-NX finding, so covering it here would report
|
|
350
|
+
the same defect twice.
|
|
351
|
+
|
|
352
|
+
Args:
|
|
353
|
+
parsed_obj: The parsed ELF binary.
|
|
354
|
+
|
|
355
|
+
Returns:
|
|
356
|
+
A list of segment descriptors with a name, normalized permissions and
|
|
357
|
+
the load address, usable as evidence for the W^X check.
|
|
358
|
+
"""
|
|
359
|
+
wx_segments: list[dict] = []
|
|
360
|
+
segments = getattr(parsed_obj, "segments", None)
|
|
361
|
+
if not segments or isinstance(segments, lief.lief_errors):
|
|
362
|
+
return wx_segments
|
|
363
|
+
with contextlib.suppress(AttributeError, TypeError):
|
|
364
|
+
for index, segment in enumerate(segments):
|
|
365
|
+
if segment.type != lief.ELF.Segment.TYPE.LOAD:
|
|
366
|
+
continue
|
|
367
|
+
writable = segment.has(lief.ELF.Segment.FLAGS.W)
|
|
368
|
+
executable = segment.has(lief.ELF.Segment.FLAGS.X)
|
|
369
|
+
if writable and executable:
|
|
370
|
+
wx_segments.append(
|
|
371
|
+
{
|
|
372
|
+
"name": f"PT_LOAD[{index}]",
|
|
373
|
+
"permissions": _rwx_permissions_str(
|
|
374
|
+
segment.has(lief.ELF.Segment.FLAGS.R), writable, executable
|
|
375
|
+
),
|
|
376
|
+
"virtual_address": ADDRESS_FMT.format(segment.virtual_address).strip(),
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
return wx_segments
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def parse_pe_wx_sections(parsed_obj: lief.PE.Binary) -> list[dict]:
|
|
383
|
+
"""Collects the PE sections the loader maps both writable and executable.
|
|
384
|
+
|
|
385
|
+
Args:
|
|
386
|
+
parsed_obj: The parsed PE binary.
|
|
387
|
+
|
|
388
|
+
Returns:
|
|
389
|
+
A list of section descriptors with a name, normalized permissions and
|
|
390
|
+
the relative virtual address, usable as evidence for the W^X check.
|
|
391
|
+
"""
|
|
392
|
+
wx_sections: list[dict] = []
|
|
393
|
+
with contextlib.suppress(AttributeError, TypeError):
|
|
394
|
+
for section in parsed_obj.sections:
|
|
395
|
+
characteristics = section.characteristics_lists
|
|
396
|
+
writable = lief.PE.Section.CHARACTERISTICS.MEM_WRITE in characteristics
|
|
397
|
+
executable = lief.PE.Section.CHARACTERISTICS.MEM_EXECUTE in characteristics
|
|
398
|
+
if writable and executable:
|
|
399
|
+
wx_sections.append(
|
|
400
|
+
{
|
|
401
|
+
"name": section.name,
|
|
402
|
+
"permissions": _rwx_permissions_str(
|
|
403
|
+
lief.PE.Section.CHARACTERISTICS.MEM_READ in characteristics,
|
|
404
|
+
writable,
|
|
405
|
+
executable,
|
|
406
|
+
),
|
|
407
|
+
"virtual_address": ADDRESS_FMT.format(section.virtual_address).strip(),
|
|
408
|
+
}
|
|
409
|
+
)
|
|
410
|
+
return wx_sections
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
# Segment protections carried by mach-o load commands (mach/vm_protect.h).
|
|
414
|
+
VM_PROT_READ = 0x1
|
|
415
|
+
VM_PROT_WRITE = 0x2
|
|
416
|
+
VM_PROT_EXECUTE = 0x4
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
def parse_mach0_wx_segments(parsed_obj: lief.MachO.Binary) -> list[dict]:
|
|
420
|
+
"""Collects the Mach-O segments initially mapped both writable and executable.
|
|
421
|
+
|
|
422
|
+
Only ``init_protection`` counts as evidence: ``max_protection`` describes
|
|
423
|
+
what a segment may later be remapped to, not what it is mapped with, so a
|
|
424
|
+
permissive maximum alone does not mean writable code ever existed.
|
|
425
|
+
|
|
426
|
+
Args:
|
|
427
|
+
parsed_obj: The parsed MachO binary.
|
|
428
|
+
|
|
429
|
+
Returns:
|
|
430
|
+
A list of segment descriptors with a name, normalized permissions and
|
|
431
|
+
the virtual address, usable as evidence for the W^X check.
|
|
432
|
+
"""
|
|
433
|
+
wx_segments: list[dict] = []
|
|
434
|
+
with contextlib.suppress(AttributeError, TypeError):
|
|
435
|
+
for segment in parsed_obj.segments:
|
|
436
|
+
protection = int(segment.init_protection)
|
|
437
|
+
writable = bool(protection & VM_PROT_WRITE)
|
|
438
|
+
executable = bool(protection & VM_PROT_EXECUTE)
|
|
439
|
+
if writable and executable:
|
|
440
|
+
wx_segments.append(
|
|
441
|
+
{
|
|
442
|
+
"name": segment.name,
|
|
443
|
+
"permissions": _rwx_permissions_str(
|
|
444
|
+
bool(protection & VM_PROT_READ), writable, executable
|
|
445
|
+
),
|
|
446
|
+
"virtual_address": ADDRESS_FMT.format(segment.virtual_address).strip(),
|
|
447
|
+
}
|
|
448
|
+
)
|
|
449
|
+
return wx_segments
|
|
450
|
+
|
|
451
|
+
|
|
340
452
|
def parse_functions(functions) -> list[dict]:
|
|
341
453
|
"""
|
|
342
454
|
Parses a list of functions and returns a list of dictionaries.
|
|
@@ -517,21 +629,23 @@ def parse_wasm_metadata(
|
|
|
517
629
|
if str(imp.get("module", "")).strip()
|
|
518
630
|
}
|
|
519
631
|
)
|
|
632
|
+
wasm_analysis = report.get("analysis") or {}
|
|
633
|
+
# wasm-tools 2.1 detects 64-bit memories in the import section too
|
|
634
|
+
# (Emscripten-style modules), surfaced as the isa.memory64 capability.
|
|
520
635
|
has_wasm64_memory = any(
|
|
521
636
|
bool((mem.get("limits") or {}).get("is_64"))
|
|
522
637
|
for mem in (report.get("memories") or [])
|
|
523
638
|
if isinstance(mem, dict)
|
|
524
|
-
)
|
|
639
|
+
) or "isa.memory64" in set(wasm_analysis.get("capabilities") or [])
|
|
525
640
|
metadata["machine_type"] = "WASM64" if has_wasm64_memory else "WASM32"
|
|
526
641
|
metadata["module_version"] = report.get("module_version")
|
|
527
642
|
metadata["section_count"] = report.get("section_count", 0)
|
|
528
643
|
metadata["sections"] = report.get("sections", [])
|
|
529
644
|
metadata["wasm_errors"] = report.get("errors", [])
|
|
530
|
-
wasm_analysis = report.get("analysis") or {}
|
|
531
645
|
metadata["wasm_analysis"] = wasm_analysis
|
|
532
646
|
metadata["wasm_report"] = report
|
|
533
647
|
|
|
534
|
-
# wasm-tools 2.
|
|
648
|
+
# wasm-tools 2.x surfaces; summaries only, the full payload stays in the
|
|
535
649
|
# companion *-wasm-report.json export.
|
|
536
650
|
metadata["is_component"] = bool(report.get("is_component"))
|
|
537
651
|
toolchain = report.get("toolchain") or {}
|
|
@@ -539,6 +653,33 @@ def parse_wasm_metadata(
|
|
|
539
653
|
metadata["wasm_unknown_opcodes"] = list(
|
|
540
654
|
(wasm_analysis.get("summary") or {}).get("unknown_opcodes") or []
|
|
541
655
|
)
|
|
656
|
+
metadata["wasm_isa_capabilities"] = sorted(
|
|
657
|
+
str(cap)
|
|
658
|
+
for cap in (wasm_analysis.get("capabilities") or [])
|
|
659
|
+
if str(cap).startswith("isa.")
|
|
660
|
+
)
|
|
661
|
+
type_kinds = Counter(
|
|
662
|
+
str(t.get("kind", "func"))
|
|
663
|
+
for t in (report.get("types") or [])
|
|
664
|
+
if isinstance(t, dict)
|
|
665
|
+
)
|
|
666
|
+
metadata["wasm_types_summary"] = {
|
|
667
|
+
"total": type_kinds.total(),
|
|
668
|
+
"func": type_kinds.get("func", 0),
|
|
669
|
+
"struct": type_kinds.get("struct", 0),
|
|
670
|
+
"array": type_kinds.get("array", 0),
|
|
671
|
+
# Any composite kind a newer wasm-tools starts decoding lands here, so
|
|
672
|
+
# the per-kind counts always add up to total.
|
|
673
|
+
**{
|
|
674
|
+
kind: count
|
|
675
|
+
for kind, count in sorted(type_kinds.items())
|
|
676
|
+
if kind not in ("func", "struct", "array")
|
|
677
|
+
},
|
|
678
|
+
}
|
|
679
|
+
format_detection = (wasm_analysis.get("detections") or {}).get("format") or {}
|
|
680
|
+
metadata["wasm_debug_info_present"] = "debug_info_present" in (
|
|
681
|
+
format_detection.get("signals") or []
|
|
682
|
+
)
|
|
542
683
|
call_graph = report.get("call_graph") or {}
|
|
543
684
|
edge_kind_counts = Counter(
|
|
544
685
|
str(edge.get("kind", "unknown"))
|
|
@@ -1745,6 +1886,9 @@ def construct_security_properties(metadata: dict, parsed_obj: lief.Binary) -> di
|
|
|
1745
1886
|
has_symtab = metadata.get("static", False)
|
|
1746
1887
|
properties = {
|
|
1747
1888
|
"nx": metadata.get("has_nx", False),
|
|
1889
|
+
# True when no loadable segment maps the same pages writable and
|
|
1890
|
+
# executable, which trivially holds for formats without segments.
|
|
1891
|
+
"w_xor_x": not metadata.get("wx_segments"),
|
|
1748
1892
|
"pie": metadata.get("is_pie", False),
|
|
1749
1893
|
"relro": metadata.get("relro", "no"),
|
|
1750
1894
|
"canary": metadata.get("has_canary", False),
|
|
@@ -2532,6 +2676,7 @@ def add_elf_metadata(exe_file: str, metadata: dict, parsed_obj: lief.ELF.Binary)
|
|
|
2532
2676
|
metadata["is_targeting_android"] = parsed_obj.is_targeting_android
|
|
2533
2677
|
metadata["virtual_size"] = parsed_obj.virtual_size
|
|
2534
2678
|
metadata["has_nx"] = parsed_obj.has_nx
|
|
2679
|
+
metadata["wx_segments"] = parse_elf_wx_segments(parsed_obj)
|
|
2535
2680
|
metadata["has_interpreter"] = parsed_obj.has_interpreter
|
|
2536
2681
|
metadata["has_notes"] = parsed_obj.has_notes
|
|
2537
2682
|
metadata["has_overlay"] = parsed_obj.has_overlay
|
|
@@ -3221,6 +3366,7 @@ def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary) -
|
|
|
3221
3366
|
metadata["is_reproducible_build"] = parsed_obj.is_reproducible_build
|
|
3222
3367
|
metadata["virtual_size"] = parsed_obj.virtual_size
|
|
3223
3368
|
metadata["has_nx"] = parsed_obj.has_nx
|
|
3369
|
+
metadata["wx_segments"] = parse_pe_wx_sections(parsed_obj)
|
|
3224
3370
|
metadata["imphash_pefile"] = lief.PE.get_imphash(parsed_obj, lief.PE.IMPHASH_MODE.PEFILE)
|
|
3225
3371
|
metadata["imphash_lief"] = lief.PE.get_imphash(parsed_obj, lief.PE.IMPHASH_MODE.LIEF)
|
|
3226
3372
|
metadata = add_pe_header_data(metadata, parsed_obj)
|
|
@@ -3547,6 +3693,7 @@ def add_mach0_metadata(exe_file: str, metadata: dict, parsed_obj: lief.MachO.Bin
|
|
|
3547
3693
|
metadata["imagebase"] = parsed_obj.imagebase
|
|
3548
3694
|
metadata["is_pie"] = parsed_obj.is_pie
|
|
3549
3695
|
metadata["has_nx"] = parsed_obj.has_nx
|
|
3696
|
+
metadata["wx_segments"] = parse_mach0_wx_segments(parsed_obj)
|
|
3550
3697
|
metadata["exe_type"] = "MachO"
|
|
3551
3698
|
metadata = add_mach0_versions(exe_file, metadata, parsed_obj)
|
|
3552
3699
|
if parsed_obj.has_encryption_info and (encryption_info := parsed_obj.encryption_info):
|
|
@@ -9,6 +9,20 @@ def check_nx(f: str, metadata: dict[str, Any], rule_obj: dict[str, Any]) -> bool
|
|
|
9
9
|
return metadata.get("has_nx") is not False
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
def check_wx_segments(f: str, metadata: dict[str, Any], rule_obj: dict[str, Any]) -> bool | str: # noqa
|
|
13
|
+
# A mapping that is writable and executable at the same time turns any
|
|
14
|
+
# memory-write primitive into direct code execution, so the offending
|
|
15
|
+
# segments are reported by name.
|
|
16
|
+
names = [
|
|
17
|
+
entry.get("name")
|
|
18
|
+
for entry in metadata.get("wx_segments") or []
|
|
19
|
+
if isinstance(entry, dict) and entry.get("name")
|
|
20
|
+
]
|
|
21
|
+
if not names:
|
|
22
|
+
return True
|
|
23
|
+
return ", ".join(names[:5])
|
|
24
|
+
|
|
25
|
+
|
|
12
26
|
def check_pie(f: str, metadata: dict[str, Any], rule_obj: dict[str, Any]) -> bool: # noqa
|
|
13
27
|
return metadata.get("is_pie") is not False
|
|
14
28
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "blint"
|
|
3
|
-
version = "3.
|
|
3
|
+
version = "3.4.0"
|
|
4
4
|
description = "Linter and SBOM generator for binary files."
|
|
5
5
|
authors = [
|
|
6
6
|
{name= "Team AppThreat", email = "cloud@appthreat.com"},
|
|
@@ -20,7 +20,7 @@ dependencies = [
|
|
|
20
20
|
"apsw>=3.53.0.0",
|
|
21
21
|
"packageurl-python>=0.17.6",
|
|
22
22
|
"oras>=0.2.41",
|
|
23
|
-
"wasm-tools>=2.
|
|
23
|
+
"wasm-tools>=2.1.0",
|
|
24
24
|
]
|
|
25
25
|
license = "MIT"
|
|
26
26
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|