Enable DEP and ASLR.#371
Enable DEP and ASLR.#371phoerious merged 3 commits intokeepassxreboot:developfrom rockihack:DEP+ASLR
Conversation
|
👍 |
|
It should be verified that keepassxc follows security best practices on windows, macOS and linux. |
|
Address randomization on Linux seems to be implemented with PIC and therefore incurs a slight performance penalty (at least on x86, x86_64 doesn't have these problems as much). At least that's what I found in this (rather dated) article: https://insights.sei.cmu.edu/cert/2014/02/differences-between-aslr-on-windows-and-linux.html |
|
Alright, did some more digging. For Linux, we need the options For stack protection, The other thing we could enable is relocation read-only (relro). Partial relro is already enabled with |
|
I changed CMakeLists.txt with 2.1.2 before and with 2.1.3 (shows 2.1.2 in about) today with the modifications phoerious mentioned and i get with hardening-check under Debian Jessie: /usr/local/bin/keepassxc: with an unmodified CMakeLists.txt i get: src/keepassxc: Fortify Source functions didn't work for me with keepassx and keepassxc, but apart from that keepassxc works fine. |
|
Fortify source is enabled for release builds in CMakeLists.txt. But it might be possible, that the setting is not really applied because the regular expression in the surrounding if condition is not wrapped in double quotes. I had something like that earlier. But as I understand it, it only checks for overflows in C string functions anyway. So it would be useful at most for code on external libraries. |
|
Any news about this? Can we merge? |
|
We should add the additional flags I suggested and maybe check if there are similar flags for the Mac. |
|
According to https://en.wikipedia.org/wiki/Data_Execution_Prevention#macOS all 64-bit executables have NX stack and heap (DEP) since 10.5 and https://en.wikipedia.org/wiki/Address_space_layout_randomization#OS_X states that all executables since 10.7 support ASLR. |
|
I guess that means we only need to enable the flags for Linux and are set and ready? |
|
I think so. It seems that its enabled by default on macOS and you need to "opt-out" to disable it. |
|
DLLs on windows are relocatable by default but nevertheless DEP+ASLR should be enabled. |
|
Could you enable the option to allow me to push to your branch? I would like to add my Linux changes, but can't do so without copying the branch which would need a new PR. |
|
|
|
Then I don't know why I couldn't push. Maybe the plus in the branch name or something. I cloned your repository instead of adding it as a remote, now it works. @droidmonkey @TheZ3ro Could you have a look at the changes? I think we can merge this if you don't see any further issues. We need to rebase first, though. |
|
Travis is failing |
|
Somehow it can't find the right Zlib version. The two clang builds passed, though. Probably some Travis/Redis fuckup again. I restarted the build, let's see. |
|
Looks like the error message is just completely misleading. -Qunused-arguments appears to be a clang-specific option, so I fixed it by only applying it when clang is used as a compiler. |
|
Why did you use |
|
Because I am stupid (or my autocompletion is). I changed it and squashed the last two commits into the "Harden Linux binary" commit. |
phoerious
left a comment
There was a problem hiding this comment.
I rebased the branch, but it doesn't trigger Travis again. Seems like we have to merge it without.
- Added YubiKey 2FA integration for unlocking databases [#127] - Added TOTP support [#519] - Added CSV import tool [#146, #490] - Added KeePassXC CLI tool [#254] - Added diceware password generator [#373] - Added support for entry references [#370, #378] - Added support for Twofish encryption [#167] - Enabled DEP and ASLR for in-memory protection [#371] - Enabled single instance mode [#510] - Enabled portable mode [#645] - Enabled database lock on screensaver and session lock [#545] - Redesigned welcome screen with common features and recent databases [#292] - Multiple updates to search behavior [#168, #213, #374, #471, #603, #654] - Added auto-type fields {CLEARFIELD}, {SPACE}, {{}, {}} [#267, #427, #480] - Fixed auto-type errors on Linux [#550] - Prompt user prior to executing a cmd:// URL [#235] - Entry attributes can be protected (hidden) [#220] - Added extended ascii to password generator [#538] - Added new database icon to toolbar [#289] - Added context menu entry to empty recycle bin in databases [#520] - Added "apply" button to entry and group edit windows [#624] - Added macOS tray icon and enabled minimize on close [#583] - Fixed issues with unclean shutdowns [#170, #580] - Changed keyboard shortcut to create new database to CTRL+SHIFT+N [#515] - Compare window title to entry URLs [#556] - Implemented inline error messages [#162] - Ignore group expansion and other minor changes when making database "dirty" [#464] - Updated license and copyright information on souce files [#632] - Added contributors list to about dialog [#629]
Description
Enable Data Execution Prevention (DEP) and Address Layout Randomization (ASLR) on windows.
Motivation and Context
DEP and ASLR are simple exploit mitigation technologies. DEP is currently not enforced and ASLR is not enabled at all.
https://www.microsoft.com/security/sir/strategy/default.aspx#!section_3_3
https://blogs.technet.microsoft.com/srd/2010/12/08/on-the-effectiveness-of-dep-and-aslr/
How Has This Been Tested?
Windows 7 + ProcessExplorer
Types of changes
Checklist: