Shellcode is specific to a particular processor architecture (and usually also to an operating system ABI, execution mode, and the surrounding memory/loading conditions), because it is machine code emitted for one instruction set and calling convention; identical "portable" shellcode across distinct architectures does not exist, although source-level generators and multi-architecture payload frameworks can produce separate builds for each target.
What "specific" means here
The word shellcode is often used loosely to mean "small position-independent machine code used as a payload." In that loose sense the concept is generic: any program written to run wherever an exploit transfers control. But the bytes themselves are architecture-bound. x86-64, AArch64, ARM (A32/T32), RISC-V, MIPS, PowerPC, and WebAssembly each define different instruction encodings, register sets, calling conventions, and privileged instructions. The same byte sequence decoded under two architectures almost never performs the same operation; it typically does something meaningless or crashes.
A simple example: on x86-64, 0x90 is NOP. On AArch64 the instruction stream is decoded in 32-bit words, so 0x90 alone is not a valid isolated instruction; padding is done with explicit instructions such as NOP encoded as 0xD503201F. Similarly, an x86 int 0x80 or syscall sequence has no counterpart on ARM, where system calls use SVC (formerly SWI) and a different register assignment (for example, syscall number in x8 on AArch64 Linux rather than rax on x86-64). Rewriting an x86 Linux execve payload for AArch64 is not a byte substitution; it is a re-authoring of the instruction sequence, register setup, and syscall convention.
Layers of specificity beyond the ISA
Architecture is the primary constraint, but "runs on the same CPU" is not sufficient. Several additional layers commonly matter:
1: Execution mode and privilege level. x86 has 16/32/64-bit modes, and 32-bit shellcode often behaves differently under a 64-bit kernel depending on how the payload is invoked (compatibility mode versus native 64-bit). ARM has A32, T32 (Thumb), and A64 states; a payload assembled for one state may not decode correctly in another. Kernel-mode shellcode also differs from user-mode shellcode: it may need to avoid user-space syscall stubs, respect kernel calling conventions, and not fault on paging or SMAP/SMEP restrictions.
2: Operating system and ABI. The same architecture on Linux, Windows, macOS, and BSD exposes different system-call mechanisms, error conventions, structure layouts, and library availability. Windows shellcode frequently resolves API addresses via the PEB and export tables rather than using a syscall number; Linux shellcode often uses direct syscalls; macOS has its own syscall numbers and conventions. Shellcode that spawns a shell on one OS will generally not do so on another even on the same CPU.
3: Position independence and memory assumptions. Classic shellcode is written to be position-independent (no absolute addresses, or addresses computed relative to the current instruction pointer) so it can run after being copied into an arbitrary buffer. It also often assumes it can locate itself, avoid null bytes, and may assume writable/executable memory. Those assumptions are environmental, not architectural, and they break on systems enforcing W^X, CFI, or hardened syscall filters.
4: Endianness and word size. Big-endian MIPS or PowerPC payloads differ from little-endian variants; pointer width (32 versus 64 bits) changes instruction encoding and immediate sizes. Even within a family, endianness can be selectable (MIPS, ARM), so the same ISA name can require different bytes.
Where "portable shellcode" claims come from
It is common to see "multi-architecture shellcode" or "universal payload" in tooling. Two distinct things are being described, and conflating them causes most of the confusion:
Source-level portability. A generator or framework (for example, a payload encoder or a project that assembles per-target stubs) emits a different byte sequence for each architecture. This is portability of the source or generation process, not of the resulting bytes. It is analogous to how a C program is portable while its compiled object files are not. Runtime selection. Some payloads begin with a small dispatcher or use a polyglot trick that survives decoding on more than one architecture and then branches to an architecture-specific stage. This is rare, delicate, and usually relies on the fact that certain byte patterns are harmless on one architecture before the real jump. It does not make the substantive payload portable; it merely relocates the architecture test into the first few bytes. Polyglots are typically confined to closely related or deliberately chosen pairs and are not a general solution. Interpreted or VM targets. Shellcode for a bytecode VM (for example, JavaScript or a managed runtime) is "architecture-independent" only in the sense that the VM is the actual execution target; the native code the VM eventually runs is still architecture-specific. That is a different threat model and different constraints.
The reverse confusion also appears: people assume that because shellcode is often short and uses syscalls, it must be CPU-agnostic because "syscalls are the OS interface." That is backwards. The syscall interface is defined by the OS and the ISA's instruction for entering the kernel, and the register/stack conventions for passing arguments are dictated by the architecture's ABI. There is no architecture-neutral syscall instruction.
Concrete contrasts
x86-64 Linux execve("/bin/sh", ...): typically sets rax to 59 (or 59 decimal in the 64-bit syscall table), places a pointer to "/bin/sh" in rdi, a pointer array in rsi, null in rdx, and executes syscall. Optimizations often zero registers via xor to avoid null bytes. AArch64 Linux: sets x8 to 221 for execve (the 64-bit syscall number), x0 to the pathname pointer, x1 to argv, x2 to envp, and executes svc #0. 32-bit x86 Linux: uses int 0x80 with the syscall number in eax (11 for execve) and arguments in ebx, ecx, edx. Windows x64: shellcode more commonly resolves kernel32/ntdll function addresses and calls them, because syscall numbers vary across Windows versions; the calling convention (RCX, RDX, R8, R9, shadow space) is specific to the platform ABI.
These are not interchangeable, and no single byte string performs all three.
Historical note on the name
The term "shellcode" arose from payloads whose purpose was to spawn a command shell, especially in the 1990s exploitation literature. As payloads diversified (reverse shells, bind shells, downloaders, staging stubs, in-memory loaders), "shellcode" became a catch-all for position-independent native payload code. The name is historical; the architecture dependence is intrinsic. Older exploits were overwhelmingly x86 because that was the dominant target, which encouraged a false intuition that "shellcode" means "x86 bytes," but 32-bit and 64-bit x86 payloads already differ, and non-x86 payloads are routine in embedded, mobile, and server environments.
What is not architecture-specific
Some properties are genuinely portable in principle: the goal (spawn a shell, map memory, connect a socket), the style of position independence, and the source-level techniques (encoding to avoid bad bytes, self-locating via a call/pop idiom adapted to the ISA). Even these require reimplementation per architecture because the idioms differ. "Avoid null bytes" is a portable objective, but the instruction choices that achieve it are architecture-specific. Likewise, "minimize size" and "avoid forbidden characters" are constraints, not encodings.
Practical implications
Exploit development: payloads must be built for the target's architecture and OS; an x86-64 payload against an AArch64 service fails at the first instruction sequence. Even within x86, a 32-bit payload injected into a 64-bit process may or may not execute depending on whether the CPU is in compatibility mode and how the exploit transfers control. Testing and detection: signature-based detection can key on architecture-specific encodings, which is one reason the same functional payload has different signatures across architectures. Tooling: assemblers, encoders, and payload frameworks take an architecture parameter; treating that parameter as cosmetic is a common source of broken payloads. Documentation: when someone says "this shellcode is portable," ask whether they mean the generator, a polyglot stub, a VM target, or the actual bytes. The answer determines which architectures it really runs on.
Summary statement
Shellcode is specific to a processor architecture because it is machine code decoded by one instruction set, and in practice it is also tied to an OS ABI, execution mode, and memory environment. "Portable shellcode" in common usage refers either to source/generator portability, to a small architecture-dispatched or polyglot stub, or to execution inside a VM, none of which removes the underlying architecture dependence of the executable payload. If the question implies a single byte sequence that runs natively across x86, ARM, and RISC-V, the answer is no; if it asks whether the idea or the toolchain can target many architectures, the answer is yes, one build at a time.