[comp.os.minix] 8086/8088 Stack Overwrite Vulnerability

jim@felix.UUCP (02/09/87)

Stuart Lynne has, with some considerable vigor ("RTFM!" several times),
claimed that 8086/8 code emitted by compilers using only intra-segment
calls and returns is not vulnerable to programs overwriting the stack.

So long as you are lucky, he is right.  Suppose, however, that 
we have only intra-segment calls, and the routine called modifies
the saved return address to coincidentally point into the middle of
an instruction, perhaps containing some 16-bit immediate data which
happens to be an inter-segment return op code.  Well, the processor will
cheerfully return to the code segment it came from, pick up the
data thinking its an opcode, interpret it as an intersegment return
and transfer to wherever the other scribbled-over words on the stack point.
I admit that this is a multiple-step process.  But the hole is there unless
Stuart is willing to insist that the compilers never generate intersegment
return opcodes as part of any instruction after the opcode byte, which seems
a bit Draconian.

It is, of course, possible to provide completely safe multi-user programming
environments on such an architecture.  One could implement a type-cheating
proof Pascal, a BASIC dialect without user access to assembly level
features, or so forth.  Most C implementations are, however, vulnerable
to the kinds of shenanigans described.

Jim Gilbert

...hplabs!felix!jim

(Ninety-five per cent of the men who have tried camels prefer women.)