Skip to main content

Linux Stack Protection By Default

Modern gcc compiler (v9.2.0) protects the stack by default and you will notice it because instead of SIGSEGV on stack overflow you will get a SIGABRT, but it also generates coredumps.




In this case the compiler adds the variable local_10. This variable helds a canary value that is checked at the end of the function.
The memset overflows the four bytes stack variable and modifies the canary value.



The 64bits canary 0x5429851ebaf95800 can't be predicted, but in specific situations is not re-generated and can be bruteforced or in other situations can be leaked from memory for example using a format string vulnerability or an arbitrary read wihout overflowing the stack.

If the canary doesn't match, the libc function __stack_chck_fail is called and terminates the prorgam with a SIGABORT which generates a coredump, in the case of archlinux managed by systemd and are stored on "/var/lib/systemd/coredump/"


❯❯❯ ./test 
*** stack smashing detected ***: terminated
fish: './test' terminated by signal SIGABRT (Abort)

❯❯❯ sudo lz4 -d core.test.1000.c611b7caa58a4fa3bcf403e6eac95bb0.1121.1574354610000000.lz4
[sudo] password for xxxx: 
Decoding file core.test.1000.c611b7caa58a4fa3bcf403e6eac95bb0.1121.1574354610000000 
core.test.1000.c611b : decoded 249856 bytes 

 ❯❯❯ sudo gdb /home/xxxx/test core.test.1000.c611b7caa58a4fa3bcf403e6eac95bb0.1121.1574354610000000 -q 


We specify the binary and the core file as a gdb parameters. We can see only one LWP (light weight process) or linux thread, so in this case is quicker to check. First of all lets see the back trace, because in this case the execution don't terminate in the segfaulted return.




We can see on frame 5 the address were it would had returned to main if it wouldn't aborted.



Happy Idea: we can use this stack canary aborts to detect stack overflows. In Debian with prevous versions it will be exploitable depending on the compilation flags used.
And note that the canary is located as the last variable in the stack so the previous variables can be overwritten without problems.




Related news

Comments

Popular posts from this blog

9774 hash passwords

blake2b-256(jade41) blake2b-256(jade420) blake2b-256(jade429) blake2b-256(jade44) blake2b-256(jade456) blake2b-256(jade4ever69) blake2b-256(jade50) blake2b-256(jade5264) blake2b-256(jade555) blake2b-256(jade5565) blake2b-256(jade69) blake2b-256(Jade69) blake2b-256(jade98) blake2b-256(jadebaby11121) blake2b-256(jadebink) blake2b-256(jadeblue) blake2b-256(jadecape) blake2b-256(jadeck) blake2b-256(jadeclub) blake2b-256(jaded) blake2b-256(jaded1) blake2b-256(jaded2) blake2b-256(jaded69) blake2b-256(jadedbaby) blake2b-256(jadedd) blake2b-256(jadedragonflower) blake2b-256(jadeds) blake2b-256(jadeduck) blake2b-256(jadeee) blake2b-256(jadeeeee) blake2b-256(jadefox) blake2b-256(jadehungder) blake2b-256(jadejade) blake2b-256(jadejord) blake2b-256(jadejs) blake2b-256(jadeland) blake2b-256(jadelilly) blake2b-256(jadelugo) blake2b-256(jadelyn) blake2b-256(jadelynn) blake2b-256(jadelynp) blake2b-256(jaden) blake2b-256(jaden0) blake2b-256(jaden1) blake2b-2...

The Base Blockchain Airdrop: Hidden Opportunities You Don’t Want to Miss!

The Base blockchain, supported by Coinbase, is making waves in the crypto space with its surging Total Value Locked (TVL) and potential airdrop opportunities. In this article, we'll dive deep into Base's ecosystem, its key protocols, and strategies for maximizing potential rewards. We'll also explore SynFutures, a standout perpetual protocol, and other exciting opportunities that could set the stage for a lucrative airdrop. Base Blockchain: A Rising Star Current Status Base has climbed to the sixth position among blockchains in terms of TVL, surpassing even Arbitrum, the long-time leader in Ethereum Layer 2 solutions. With $4 billion+ in TVL , Base's rapid growth is drawing attention from the crypto community. Why the Excitement Around a Potential Airdrop? Coinbase Backing: As a leading exchange, Coinbase's involvement ensures credibility and innovation. Changing Regulations: With evolving regulatory clarity, there's renewed optimism for potential rewards lik...

5525 Interesting News

TikTok Restoring Service for U.S. Users, After Trump Signals He Will Save It The pandemic has changed the shape of global happiness The "Scream" franchise adds another self-referential sequel Millions of Chinese people play guandan. Is that good or bad? A theatre in Jenin offers a different kind of Palestinian resistance Economic data, commodities and markets Covid-19 has shone a light on racial disparities in health Is Syria's drug-dealing dictator coming in from the cold? Female soldiers are changing how armed forces work This Tool Probes Frontier AI Models for Lapses in Intelligence How much cash should be removed from the financial system? Can the voluntary carbon market save the Amazon? File-Unpumper - Tool That Can Be Used To Trim Useless Things From A PE File Such As The Things A File Pumper Would Add This week's cover War in space is no longer science fiction The best Apple deals you can get right now: Save on Apple TV+, AirPods, iPads and more Trump's Agg...