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 word


Comments

Popular posts from this blog

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...

When Berachain Meets AI: 9 Projects Riding the Next Big Wave

Artificial Intelligence (AI) and blockchain are arguably two of the hottest narratives in tech today. With Berachain's mainnet launch just around the corner, combining AI with this innovative blockchain opens up exciting possibilities. In this article, we'll dive into nine AI-driven projects on Berachain, each offering unique use cases and solutions. Baosdotfun 1. Baosdotfun: The Launchpad for AI DAOs Baosdotfun acts as an incubator for AI-driven DAOs, focusing on areas like yield farming and trading strategies. Their "DAO seasons" introduce new AI agents every few months, providing fresh opportunities for users. Key features: Supports multiple AI agents. Focus on decentralized autonomous organizations (DAOs). Official Links: Baosdotfun Website Baosdotfun on Twitter Beradigm 2. Beradigm: Maximizing BGT Farming Beradigm specializes in yield farming to accumulate BGT, a governance token central to Berachain's ecosystem. Using AI, Beradigm optimizes farming strategie...

6 Airdrops You Probably Won — Check Now and Claim Your Rewards!

6 Airdrops You Probably Won — Check Now and Claim Your Rewards! The world of cryptocurrency is witnessing yet another resurgence of airdrops, with projects rushing to capitalize on the market's bullish momentum. These distributions present a golden opportunity for crypto enthusiasts to claim free tokens, often with significant market valuations. In this guide, we'll break down six exciting airdrops that are currently claimable and provide actionable steps to maximize your rewards. Why Cryptocurrency Airdrops Are a Big Deal Airdrops are not a new phenomenon in the crypto world, but their resurgence in 2024 has been remarkable. Two main factors contribute to their growing popularity: 1. High Market Valuations: Recent examples include: Hype by Hyper Liquid: Market cap peaked at $10 billion. Move by Movement: Touched $2.3 billion. Pengu by Pudgy Penguins: Reached $4.2 billion during its launch. 2. Frenzied Project Launches: Many projects are fast-tracking token releases to rid...