Togoder security

Go package security report

github.com/bytedance/sonic/loader Go module: is it safe?

Critical: dangerous or likely malicious code found.

Critical risk Version v0.5.2 Files reviewed 47 Size 251.4 KB Scanned

Summary

Togoder Security scanned the Go package github.com/bytedance/sonic/loader@v0.5.2 on Oct 5, 2026. An AI review of 47 source files produced 2 critical, 9 high, 32 medium, 14 low severity findings. At least one finding describes dangerous behavior such as code that runs at install time, credential access or data exfiltration. Do not install this version until you have reviewed the findings below.

2
critical
9
high
32
medium
14
low

Findings 57

critical

Arbitrary code loading and execution

NPS-D96BDDFC3914

The Load function dynamically loads and registers functions from raw byte slices (text and code), allowing execution of arbitrary machine code. This is a high-risk pattern often used in exploits or rootkits to inject and run malicious payloads without standard compilation or verification.

wrapper.go:77
critical

Dynamic code execution and memory manipulation

NPS-95BB88504268

The code uses unsafe.Pointer, reflection, and direct memory manipulation to load and execute arbitrary machine code at runtime via the WrapGoC and Load functions. This bypasses Go's memory safety and can execute untrusted native code, potentially leading to code execution, privilege escalation, or system compromise.

wrapper.go:97
high

Low-level memory manipulation using unsafe

NPS-E626C87D134A

The file heavily uses the 'unsafe' package to construct moduledata and pclntable structures, directly manipulating Go runtime internals. This is typical for bytecode/JIT loaders (like bytedance/sonic) but is a significant security concern if used maliciously or if inputs are not strictly validated. It can lead to memory corruption, arbitrary code execution, or sandbox escape.

funcdata_go117.go
high

Runtime memory mapping and execution

NPS-E2177C706E13

Functions mmap() and mprotect() are called to allocate memory and mark it executable before copying provided machine code into it. The source of 'text' is not shown here but if attacker-controlled, this effectively allows arbitrary native code execution (JIT), which is a backdoor-like capability.

funcdata_go117.go
high

Unsafe memory manipulation

NPS-63E132AD6460

The code uses unsafe.Pointer and pointer arithmetic to construct slices from token pointers, bypassing Go's type safety. This pattern is highly unusual for a parser and can lead to memory corruption, out-of-bounds reads, or undefined behavior if the underlying pointer is invalid.

internal/iasm/expr/parser.go:64
high

Undefined behavior / memory safety violation

NPS-27E5802664E4

In tokenName, it takes the address of the first rune of a local slice (&v[0]) and stores it in a token. The token may outlive the slice's backing array, causing a dangling pointer. Later, rbuf reconstructs a slice from this pointer with length and capacity from u64, which could read arbitrary memory if the pointer is invalid.

internal/iasm/expr/parser.go:64
high

Dynamic code generation and loading

NPS-98C41F1D80A1

The code loads raw machine code (text []byte) into Go's runtime using a custom Loader and registerModule, effectively performing dynamic code execution at runtime. This is highly unusual for normal Go packages and could be abused to execute arbitrary native code if the input is attacker-controlled.

loader_latest.go:137
high

Unsafe pointer manipulation

NPS-565FFEFCE2D1

The Load function returns Function pointers derived from raw memory addresses (mod.text + EntryOff) using unsafe pointer conversions. This bypasses Go's type safety and can lead to memory corruption or arbitrary code execution.

loader_latest.go:149
high

Dynamic code execution / memory manipulation

NPS-8FE2979C70B8

The code allocates executable memory using VirtualAlloc with PAGE_READWRITE, then changes it to PAGE_EXECUTE_READ with VirtualProtect. This pattern is commonly used to load and execute arbitrary code (shellcode) at runtime, which is a significant security concern in a third-party package. While it is part of a legitimate loader package (likely for plugins or JIT), such capabilities can be abused for malicious purposes such as backdoor installation or running unauthorized code.

mmap_windows.go:34
high

Bypass of Go runtime safety mechanisms

NPS-9BBCE16F222F

The code disables async preemption (PCDATA_UnsafePointUnsafe) and manually constructs stack maps and PC data, which can undermine Go's runtime safety, making the program vulnerable to crashes, memory corruption, or exploitation.

wrapper.go:53
high

Unsafe reflection and pointer arithmetic

NPS-A6DD92B58435

Extensive use of unsafe.Pointer and reflect.TypeOf to manipulate function pointers and stack layouts (e.g., rt.UnpackEface, *(*Function)(w.Value) = gofuncs[i]) can be exploited to corrupt memory, bypass security checks, or achieve arbitrary code execution.

wrapper.go:152
medium

runtime code generation / unsafe memory manipulation

NPS-F147711BB16D

This file is part of a Go runtime loader that constructs internal runtime structures (moduledata, pcHeader, pclntab, findfunctab) at runtime. It directly writes into memory using unsafe.Pointer, calls mmap/mprotect (via rt package), and builds executable code segments. While this is a legitimate technique used by the ByteDance Sonic JIT loader, the pattern is inherently powerful and can be weaponized for code injection or bypassing security boundaries.

funcdata_compat.go
medium

Direct modification of Go runtime structures

NPS-E5D757CE43DC

Creates fake moduledata and pcHeader with magic 0xfffffffa, and mutates moduleCache. This manipulates the Go runtime's function tables, which could be abused to hook or redirect calls, hide malicious code, or bypass security checks.

funcdata_go117.go
medium

Unsafe pointer usage

NPS-13213467A0E7

The code imports 'unsafe' and defines structs that mirror Go runtime internal moduledata and _func structures using unsafe.Pointer fields. While this is common for low-level runtime introspection libraries (e.g., for performance profiling or patching), direct manipulation of Go runtime internals via unsafe can lead to memory corruption or undefined behavior if misused.

funcdata_go121.go:22
medium

Runtime internal structure access

NPS-FEF1F2C7FDB9

The file defines a 'moduledata' struct that replicates internal Go runtime structures, including function metadata (pclntable, ftab, findfunctab) and pointers to runtime type information. Accessing or modifying these structures can be used to bypass security mechanisms, alter function behavior, or extract sensitive runtime information.

funcdata_go121.go:26
medium

Unsafe usage

NPS-27E01CEB74C6

The code uses the unsafe package to directly manipulate internal Go runtime structures (moduledata, _func). This is not inherently malicious but indicates low-level runtime manipulation typical of instrumentation or hooking libraries. Such code could be abused for runtime patching, but no specific malicious behavior is present.

funcdata_go123.go:19
medium

Low-level runtime manipulation

NPS-F841A7D3E317

The package uses //go:linkname to directly link against the Go runtime's runtime.morestack_noctxt function. This is a powerful and fragile mechanism that bypasses normal Go safety checks and relies on internal runtime implementation details. While not inherently malicious, this technique is commonly used in memory-corruption/exploit-adjacent code and assembly-level manipulations, and it can be used to subvert expected runtime behavior.

internal/abi/stubs.go
medium

Potential information leak

NPS-7E72684CBF8E

The rbuf method can be used to create a slice from any pointer stored in a _Token. If an attacker can influence token creation or the u64 field, it could read arbitrary memory contents as runes, potentially leaking sensitive data from the process memory.

internal/iasm/expr/parser.go:57
medium

File system manipulation outside package scope

NPS-107EA8355F4C

The Generate method creates a file at an arbitrary caller-supplied path and then chmods it to 0755 (executable). While this is the intended API for generating executables, writing executables anywhere on the filesystem and granting execute permissions can be abused if the path is attacker-controlled. This is a capability, not an inherent backdoor, but it should be noted.

internal/iasm/obj/obj.go:63
medium

Executable file generation without validation

NPS-7A57BA8AE623

The Format.Generate method produces native ELF/Mach-O binaries from raw code bytes with no validation or sandboxing. If this library is used with untrusted input, it could facilitate dropping malicious executables to disk.

internal/iasm/obj/obj.go:72
medium

Unsafe memory manipulation

NPS-CC454DF08240

The code uses unsafe.Pointer and reflect internals to directly reinterpret interface{} memory layouts (_GoEface, _GoType, _GoSlice). This bypasses Go's type safety and relies on undocumented internal runtime structures that may change between Go versions. While this pattern is commonly used in legitimate performance-sensitive libraries (e.g., CloudWeGo's iasm assembler), it can lead to memory corruption or crashes if misused, and could in theory be weaponized to read arbitrary memory via the toInt64() method which dereferences self.ptr based on vt.size without bounds validation.

internal/iasm/x86_64/eface.go
medium

unsafe code / low-level memory manipulation

NPS-4AE40318481A

The file uses unsafe.Pointer, //go:linkname to runtime internals (growslice, memclrNoHeapPointers), and manual slice header manipulation in expandmm. While typical for an assembler package, linkname usage bypasses Go's type safety and could break across Go versions or be abused if the package were compromised.

internal/iasm/x86_64/utils.go
medium

Unsafe memory manipulation

NPS-35DE70720766

The functions in this file use the unsafe package to perform direct memory manipulation, casting between string, []byte, and raw pointers. This bypasses Go's memory safety guarantees and can lead to memory corruption, data races, or security vulnerabilities if misused. Functions like Mem2Str, Str2Mem, BytesFrom, IndexChar, and IndexByte are heavily dependent on exact memory layout assumptions and lack bounds checking.

internal/rt/fastmem.go
medium

Potential for malicious exploitation

NPS-76A491C58C5B

The unsafe primitives provided by this file (e.g., direct pointer arithmetic in IndexChar and IndexByte, arbitrary slice creation from pointers in BytesFrom) could be leveraged by an attacker to read or write arbitrary memory if the caller passes untrusted or incorrectly computed arguments. While the functions themselves are not overtly malicious, they significantly lower the bar for exploiting memory-safety bugs elsewhere in the program.

internal/rt/fastmem.go
medium

Use of unsafe and reflect internals

NPS-2ADC9C372423

The file heavily uses Go's unsafe package and directly manipulates internal runtime type representations (GoType, GoIface, GoEface, GoItab). This circumvents Go's type safety and is highly dependent on implementation details, making it fragile and potentially exploitable if types are mismanaged.

internal/rt/fastvalue.go
medium

Type confusion vulnerability

NPS-084B87FE3C93

Functions like UnpackType, UnpackEface, and UnpackIface cast arbitrary interface{} or reflect.Type values to internal structures without validation. If used with unexpected types, this can lead to memory corruption or crashes.

internal/rt/fastvalue.go
medium

Potential for arbitrary memory read/write

NPS-DF3C62733683

The code provides direct access to raw pointers and type metadata (e.g., GoType, GoMapType, GoSlice). While the intent is performance optimization, a malicious actor could exploit these functions to read or write arbitrary memory if they control input types or interfaces.

internal/rt/fastvalue.go
medium

Missing bounds checks in critical functions

NPS-60C529BAEEC9

The Bit method does no bounds checking on self.N or the pointer self.B, allowing out-of-bounds reads if i >= N or if the underlying memory is insufficient. Similarly, Get does not validate i against self.N before doing pointer arithmetic, potentially causing out-of-bounds access.

internal/rt/stackmap.go:112
medium

Unsafe pointer arithmetic

NPS-26576B7E61F0

Multiple functions (Get, Bit, MarshalBinary, Build) use unsafe.Pointer and uintptr arithmetic to directly manipulate memory. In Go, improper use of unsafe.Pointer with uintptr (especially when converting back to unsafe.Pointer) can violate the unsafe.Pointer safety rules, leading to memory corruption or undefined behavior. While likely intentional for low-level runtime purposes, it is a security risk if inputs are not strictly validated.

internal/rt/stackmap.go:142
medium

go:linkname usage

NPS-0B931D3F3950

The directive //go:linkname is used to link to runtime.mallocgc, bypassing Go's type safety and package encapsulation. This can break in future Go versions and allows direct calls to runtime internals, which is a potential security concern if misused.

internal/rt/stackmap.go:187
medium

Potential integer overflow in size calculation

NPS-FCDB57890D99

In StackMapBuilder.Build, allocatedSize is computed as _StackMapSize + uintptr(nb) - 1. If nb is 0 or large, integer underflow/overflow could occur, leading to incorrect memory allocation. Additionally, BinaryLen multiplies BitmapBytes() * BitmapNums() without overflow checks, which could be exploited if the struct is populated with crafted values.

internal/rt/stackmap.go:199
medium

Module loading capability

NPS-DBF062DF1F14

The Loader struct (with Name, File, Options) and NoPreempt option suggest this package is designed to dynamically load and patch a Go module at a binary level, potentially with async preemption disabled. Dynamic module/binary loading with preemption disabled can be used to hide execution from the Go runtime and routine profiling/debugging, which is a red flag for stealthy code injection if inputs are attacker-controlled.

loader.go
medium

Unsafe pointer usage

NPS-888AF634C6B9

The Function type is defined as unsafe.Pointer, which is used for direct memory manipulation. While this file itself does not perform malicious actions, this pattern is typical of low-level runtime patching/module loading code (as in ByteDance's Frugal/monkey-patching libraries) and can be abused to bypass Go's type safety, hook functions, and execute arbitrary in-memory code. It warrants scrutiny in the broader package context.

loader.go:19
medium

Runtime patching of Go module data

NPS-40FD18F11436

The code calls moduledataverify1 and registerModule to modify the Go runtime's module data structures at runtime. Legitimate packages rarely need to do this; such behavior is typical of malware or runtime exploitation frameworks.

loader_latest.go:141
medium

RWX memory / dynamic code execution capability

NPS-4E6EDE1C1999

The mmap function allocates anonymous private memory with read-write permissions, and mprotect subsequently changes that same memory region to read-execute (_RX = PROT_READ | PROT_EXEC). This is the classic pattern for a JIT or dynamic code loader that writes executable code into memory at runtime and then executes it. While this package (ByteDance loader) is a legitimate component used by projects like Sonic for runtime code generation, the same pattern is frequently used by malware to hide shellcode and payloads from static analysis. The allocation and execution are gated behind a 'loader' package but the functions are exported and could be invoked from any importing code.

mmap_unix.go:33
medium

W^X violation / executable memory

NPS-43E5F3EAD551

mprotect marks pages as PROT_EXEC after they were writable, allowing dynamically-written bytes to be executed. No address range validation, no size bounds check, and no verification that the region was previously allocated by mmap before flipping it to executable. Combined with the fact that the caller controls 'p' (uintptr) and 'nb' (int), a caller could potentially mark arbitrary memory ranges executable.

mmap_unix.go:41
medium

Use of unsafe and runtime memory manipulation

NPS-7861D30769FF

The code heavily uses unsafe.Pointer, rt.BytesFrom, mmap, mprotect, and directly manipulates Go runtime metadata structures (moduledata, pclntab, functab, findfunctab). While this is legitimate for a low-level loader (bytedance/sonic), such operations are highly sensitive and could be abused to modify or hide code, bypass security checks, or create malicious runtime structures.

moduledata.go
medium

Runtime memory allocation and protection changes

NPS-F0CC5D3D66F0

The makeModuledata function calls mmap to allocate executable memory, copies machine code into it, and calls mprotect to make it executable. This is a classic pattern for JIT/loader functionality but also for shellcode execution or runtime code injection if used maliciously.

moduledata.go
medium

Direct manipulation of Go runtime internals

NPS-5EE4B7D84520

The code constructs and modifies internal Go runtime structures such as pcHeader, moduledata, _func, and findfuncbucket. Tampering with these can alter function resolution, stack traces, and potentially hide malicious activity from runtime introspection.

moduledata.go
medium

Low-level runtime modification using unsafe pointers

NPS-8754228446C0

The file uses unsafe.Pointer and atomic operations to directly modify Go runtime internal data structures (moduledata, lastmoduledatap). This is highly unusual for a normal package and indicates deep runtime manipulation, which could be used to hide or load modules in a non-standard way. While not overtly malicious, such techniques are typically reserved for the Go runtime itself or very specialized tools, and could be used to bypass security controls or load unauthorized code.

register.go
medium

Potential for module loading manipulation

NPS-A4D3DA7BBDCB

The registerModule and registerModuleLockFree functions link a new moduledata into the runtime's module list. This could allow dynamically loaded code to appear as a legitimate Go module, potentially evading detection by module verification tools. The build tag '!bytedance_tango' suggests this code is excluded in certain builds, indicating it is part of a customized runtime environment, which may be used for legitimate performance tuning but also carries risk if misused.

register.go
medium

unsafe linkname usage

NPS-EBD549A617F0

The file uses //go:linkname to access plugin.pluginsMu, an unexported internal runtime variable, which relies on unsupported linker behavior and can break or be abused across Go versions. While the code only registers a new module in the plugin list, this pattern can be used for undocumented runtime manipulation and is generally discouraged in public registry packages.

register_tango.go:23
medium

Unsafe runtime access via //go:linkname

NPS-6FB6B4FABB48

The file uses //go:linkname directives to access unexported runtime symbols (runtime.lastmoduledatap and runtime.moduledataverify1). This bypasses Go's encapsulation and can be used to manipulate runtime module data or disable verification, though no active malicious behavior is present in this file.

stubs.go:21
low

empty stub function / potential hook

NPS-73D5B5BD979B

The function registerFunction(...) is a no-op that takes raw pointer addresses (pc, argptrs, localptrs). It appears to be a placeholder/hook that could be replaced in other builds to perform arbitrary registration or execution. In this file it is benign, but its presence is worth flagging as a potential vector if overridden.

funcdata_compat.go
low

build tag targeting old Go versions (!go1.17)

NPS-210C407A6FDE

The file is only compiled for Go < 1.17, which may indicate compatibility shims. This is not malicious by itself, but the build-tagging reduces visibility during review on modern toolchains.

funcdata_compat.go:1
low

No malicious behavior detected

NPS-AB727D9A5758

The code does not contain any network requests, environment variable harvesting, shell command execution, dynamic code evaluation, or other common malicious patterns. It appears to be a legitimate low-level loader library for function metadata, likely used by the bytedance/sonic JSON library for performance optimizations.

funcdata_go121.go
low

Internal package import

NPS-9F0A6E7E5D9F

Imports 'github.com/bytedance/sonic/loader/internal/rt', an internal package. This restricts usage to the same module but is not a security concern per se.

funcdata_go123.go:20
low

build-tag constrained beyond current Go releases

NPS-25E4EF46640B

The build constraint targets go1.26 (a future release). This suggests speculative support for unpublished Go versions, which may indicate forks or patched toolchains, but no malicious behavior is present.

funcdata_go126.go:1
low

unsafe pointer / runtime internals manipulation

NPS-4BB3B657B72B

The code imports 'unsafe' and defines low-level runtime data structures (moduledata, _func) mirroring Go's internal runtime layout. This is typical of Go runtime patching libraries (e.g., ByteDance's sonic loader) and is not inherently malicious, but interacting with runtime internals via unsafe pointers can introduce memory-safety risks and is highly version-dependent.

funcdata_go126.go:19
low

version-specific build constraints

NPS-5CFC607F3206

Build tags restrict this file to Go 1.27 only. The comments describe modifications to runtime internal structures (moduledata layout changes). This is a legitimate approach for maintaining compatibility with multiple Go versions, not a red flag per se.

funcdata_go127.go:1
low

unsafe pointer usage

NPS-C23D16B66A46

The code uses the unsafe package and manipulates internal runtime structures (moduledata, _func, funcTab) with hardcoded offsets. This is typical for low-level runtime introspection libraries, but is fragile and version-specific. It does not itself indicate malicious intent, but such code can be used to bypass memory safety.

funcdata_go127.go:18
low

Low-level assembly generation for runtime function calls

NPS-3130502C6EF9

The code generates x86-64 machine code to call runtime.morestack_noctxt and arbitrary native functions via a uintptr address (CallC). This is a legitimate part of ByteDance's sonic loader for Go ABI manipulation, but it enables dynamic native code invocation which could be abused if addr is attacker-controlled. No external network, filesystem, or process-spawning behavior is present.

internal/abi/abi_amd64.go
low

Unsafe runtime access

NPS-02DD4EB0FAFB

The file declares a constant _G_stackguard0 = 0x10, which corresponds to an internal offset in the Go runtime's g (goroutine) structure. Combined with the linkname stub, this suggests the package may be manipulating goroutine stack guard values directly, which is a low-level memory manipulation technique that can lead to undefined behavior or be abused for exploitation.

internal/abi/stubs.go
low

reflect-based type extraction

NPS-C59A7129915D

byteType is derived via efaceOf and unsafe pointer extraction from reflect.TypeOf(byte(0)). This is a fragile internal representation technique that relies on runtime layout details.

internal/iasm/x86_64/utils.go
low

manual memory fill

NPS-035DB9DFAF68

memset/memsetv perform raw pointer writes with unsafe.Pointer arithmetic. This is legitimate low-level code but represents a potential memory-safety hazard if bounds are incorrect.

internal/iasm/x86_64/utils.go
low

No direct malicious intent detected

NPS-F5B06E077072

Despite the use of unsafe patterns, the code does not contain data exfiltration, credential harvesting, obfuscation, network calls, or process execution. It appears to be a legitimate performance-oriented utility (likely from a JSON library like Sonic) for fast reflection-based value manipulation.

internal/rt/fastvalue.go
low

build-tag gated runtime mutation

NPS-217F2E451BB6

The file is gated behind the bytedance_tango build tag, meaning its behavior only activates under a specific non-default build configuration. Such hidden build conditions can mask behavior from ordinary users and reviewers, especially when combined with //go:linkname runtime modification.

register_tango.go:1

Files reviewed

FileVerdictWhat the reviewer saw
wrapper.go critical The code performs dynamic loading and execution of arbitrary machine code via unsafe memory manipulation and reflection, posing a critical security risk for code execution and memory corruption.
funcdata_compat.go medium This is a legitimate but extremely low-level Go runtime loader that performs unsafe memory writes and builds executable pages; no direct exfiltration or backdoor behavior is present, but the unsafe/manual runtime manipulation warrants review in context of the full package.
funcdata_go117.go medium This file is a low-level JIT/loader implementation using unsafe memory manipulation and executable memory mapping; not inherently malicious but highly dangerous if misused or fed untrusted input.
funcdata_go121.go medium The file uses unsafe pointers to access Go runtime internals for function metadata, which poses a medium risk of memory corruption if misused, but no malicious patterns were detected.
funcdata_go123.go medium The file contains low-level runtime structure definitions using unsafe pointers, which is typical for instrumentation libraries and not inherently malicious; no exfiltration, credential harvesting, or backdoor patterns were found.
funcdata_go126.go medium The file is a legitimate-looking Go runtime loader shim using unsafe and internal runtime structs for Go 1.26; no malicious patterns such as exfiltration, credential harvesting, shell execution, or obfuscated payloads were detected.
funcdata_go127.go medium The file is a legitimate Go runtime introspection helper from the ByteDance Sonic library that uses unsafe pointers to access internal moduledata structures; no malicious patterns such as data exfiltration, credential harvesting, or backdoors were found.
internal/abi/abi_amd64.go medium The file contains low-level x86-64 assembly generation for Go ABI handling (stack growth, argument spilling, C function invocation); it is part of ByteDance's legitimate sonic library with no exfiltration, credential harvesting, obfuscation, or process/network side effects detected.
internal/abi/stubs.go medium The code is not a typical malicious package but uses unsafe low-level Go runtime manipulation (go:linkname to runtime.morestack_noctxt) and internal struct offsets, which is a warning-level practice requiring trust in the package source.
internal/iasm/expr/parser.go medium The parser uses unsafe pointer manipulation to construct strings from tokens, introducing memory safety risks and potential undefined behavior, but no direct malicious patterns (exfiltration, backdoors, or code execution) were found.
internal/iasm/obj/obj.go medium The code is a legitimate assembly/binary generation utility, but it writes arbitrary caller-supplied code to files and makes them executable (chmod 0755), which is a dual-use capability that could be abused if inputs are untrusted.
internal/iasm/x86_64/eface.go medium The code is a low-level Go runtime type introspection utility using unsafe.Pointer to read interface internals; it contains no exfiltration, network, shell, lifecycle, or backdoor patterns, but relies on undocumented runtime memory layouts that carry inherent type-safety risks.
internal/iasm/x86_64/utils.go medium No malicious patterns such as exfiltration, credential harvesting, backdoors, or process spawning were found; the code is a legitimate x86-64 assembler utility using low-level unsafe and runtime internals, which carries inherent risk but is not malicious.
internal/rt/fastmem.go medium The file contains low-level unsafe memory manipulation utilities that are not inherently malicious but pose a security risk if misused or exposed to untrusted input.
internal/rt/fastvalue.go medium The code uses unsafe runtime internals and reflection, creating potential memory safety risks, but no malicious patterns such as exfiltration, credential theft, or backdoors were found.
internal/rt/stackmap.go medium The code contains intentional unsafe pointer operations and runtime linkage typical for low-level Go runtime code, but lacks sufficient bounds and overflow checks, posing medium-severity security risks if used with untrusted input.
loader.go medium This loader.go file contains no direct malicious code (no network, filesystem, exec, or credential access), but its use of unsafe.Pointer and a dynamic module loader with preemption disabling enables powerful code-patching capabilities that should be reviewed together with the rest of the package.
loader_latest.go medium The file implements a JIT-like loader that injects and executes raw machine code into the Go runtime, which is a dangerous capability that could be weaponized for arbitrary code execution if the input is not fully trusted.
mmap_unix.go medium No exfiltration, credential harvesting, network or shell activity present, but the file implements RW->RX memory mapping that enables dynamic executable code loading, a dual-use capability requiring scrutiny of the surrounding 'loader' package.
mmap_windows.go medium The file implements Windows memory allocation and protection functions that enable executable memory regions, a pattern often associated with dynamic code execution and potential shellcode loading, which warrants caution.
moduledata.go medium The code is a legitimate Go runtime loader from bytedance/sonic that uses unsafe memory manipulation and runtime metadata modification; while no direct malicious patterns are present, the low-level techniques could be abused if modified.
register.go medium The code manipulates Go runtime internals using unsafe pointers to register modules, which is suspicious and could be used to bypass security controls, though no direct malicious behavior is evident.
register_tango.go medium No data exfiltration or direct malicious behavior, but the file uses unsafe //go:linkname to modify Go runtime plugin state behind a hidden build tag, which warrants review.
stubs.go medium The code uses //go:linkname to access unexported runtime internals, a risky practice, but contains no active malicious patterns.
funcdata.go safe The code is a legitimate Go runtime/loader utility from ByteDance that constructs function metadata tables; it contains no network, filesystem, process execution, obfuscation, or credential-harvesting patterns.
Show 22 more files
FileVerdictWhat the reviewer saw
funcdata_go118.go safe No malicious patterns detected; this is a legitimate internal loader definition for Go runtime type information from the ByteDance sonic package.
funcdata_go120.go safe No malicious patterns detected; the file contains only Go runtime structure definitions and constants with no executable code or suspicious behavior.
funcdata_legacy.go safe Cleared by Jev triage; no further analysis needed
internal/abi/abi.go safe No malicious patterns detected; the code implements Go ABI layout and stack map utilities with no exfiltration, credential harvesting, dynamic execution, or network/file/process manipulation.
internal/abi/abi_legacy_amd64.go safe No malicious patterns detected; the code is legitimate low-level ABI handling for the ByteDance Go runtime.
internal/abi/abi_regabi_amd64.go safe No malicious patterns detected
internal/iasm/expr/ast.go safe Cleared by Jev triage; no further analysis needed
internal/iasm/expr/errors.go safe Cleared by Jev triage; no further analysis needed
internal/iasm/expr/ops.go safe Cleared by Jev triage; no further analysis needed
internal/iasm/expr/pools.go safe Cleared by Jev triage; no further analysis needed
internal/iasm/expr/term.go safe Cleared by Jev triage; no further analysis needed
internal/iasm/expr/utils.go safe Cleared by Jev triage; no further analysis needed
internal/iasm/obj/macho.go safe No malicious patterns detected
internal/iasm/x86_64/arch.go safe Cleared by Jev triage; no further analysis needed
internal/iasm/x86_64/encodings.go safe This file contains only x86-64 instruction encoding helper routines with no network, filesystem, process, or credential access; no malicious patterns detected.
internal/iasm/x86_64/instructions.go safe This is a code-generated x86-64 assembler instruction encoding file from CloudWeGo; it contains no malicious patterns, network calls, obfuscation, or dynamic execution.
internal/iasm/x86_64/instructions_table.go safe No malicious patterns detected
internal/iasm/x86_64/operands.go safe Cleared by Jev triage; no further analysis needed
internal/iasm/x86_64/pools.go safe Cleared by Jev triage; no further analysis needed
internal/iasm/x86_64/program.go safe This is a legitimate x86-64 instruction assembler from the ByteDance sonic library with no malicious patterns detected.
internal/iasm/x86_64/registers.go safe Cleared by Jev triage; no further analysis needed
pcdata.go safe Cleared by Jev triage; no further analysis needed

Scanned versions of github.com/bytedance/sonic/loader

VersionVerdictFilesScanned
v0.5.2 Critical risk 47 Oct 5, 2026

Frequently asked questions

Is github.com/bytedance/sonic/loader safe to use?

github.com/bytedance/sonic/loader@v0.5.2 has 2 critical, 9 high, 32 medium, 14 low severity findings, including behavior that is dangerous or likely malicious. Do not install it without reviewing the findings.

Does github.com/bytedance/sonic/loader contain malware?

The latest scan of github.com/bytedance/sonic/loader (v0.5.2) flagged critical behavior consistent with malicious or dangerous code. See the findings on this page for the exact files and lines.

How was github.com/bytedance/sonic/loader checked?

Togoder Security downloaded the published Go package and had an AI model read its 47 source files, looking for install scripts, credential access, network exfiltration, obfuscation, backdoors and crypto-wallet theft. The results are cached by file hash and shown here.

How do I scan github.com/bytedance/sonic/loader together with the rest of my dependencies?

Upload your lockfile at https://security.togoder.click/scan or call the API documented at https://security.togoder.click/api-docs. Files that have already been scanned, like the ones in github.com/bytedance/sonic/loader@v0.5.2, cost nothing.

Related security reports