52 votes
Accepted

What security measure one should implement before executing user uploaded files?

It is impossible to analyze a program to find out if it will do anything malicious. That is true regardless of whether you are attempting to analyze the source or compiled code. The way to do what ...
kasperd's user avatar
  • 5,482
28 votes

What security measure one should implement before executing user uploaded files?

This is a really hard problem, and one all online code judges has to solve. Basically, you are asking how you can prevent somebody who can execute arbitrary code on your machine from taking it over. ...
pehrs's user avatar
  • 381
8 votes
Accepted

How is compiling a program from source more secure?

It's harder to hide a backdoor in source code than in a binary. Someone could easily add a bunch of code before compiling a binary, but leave the extra code unpublished. If you build it yourself, then ...
Ben's user avatar
  • 4,022
8 votes
Accepted

Does Java anti-decompiler software really work as claimed?

No, these do not work in the way claimed. They do not and cannot prevent reverse engineering and decompiling. The most they can possibly do is obfuscate Java to make it more difficult to understand, ...
forest's user avatar
  • 66.6k
7 votes

What security measure one should implement before executing user uploaded files?

In the particular case of a puzzle website, consider the alternative: don't bother. Ask participants to upload the output so you don't have to run untrusted code. This saves you computing power, ...
Colonel Panic's user avatar
7 votes

How do I harden compilers (as suggested by Lynis)?

Security is always a balance between ease of use and protection. The most secure system I can imagine is a switched off computer lying in a bank safe. Unfortunately it is also hard to use... Removing ...
Serge Ballesta's user avatar
6 votes

Should I compile as root?

There are two different situations: 1. You are going to run the software as root In this case you should really trust the source code before using it. Either by auditing it, or by trusting the ...
joeytwiddle's user avatar
4 votes
Accepted

Compiling with GCC retpoline flags

There is a benefit from doing this. These options enabled retpoline to mitigate Spectre V2. This is important in programs which handle sensitive or confidential data where the variable performance ...
forest's user avatar
  • 66.6k
4 votes

Program compiled with mingw32 is reported as infected

Your Anti-Virus (Defender or any other software) sees a virus signature in your safe file due to: Your code is compiled by minGW. Many viruses are written in C and compiled in minGW to be small. Thus,...
hgrev's user avatar
  • 61
4 votes
Accepted

Is there a secure way to embed a private key in compiled code that is released in compiled form to the general public?

There is no way to ship the private key as pure data (i.e. no additional hardware) together with the application or inside the application, no matter if it is encrypted or not. Since it has to be ...
Steffen Ullrich's user avatar
3 votes
Accepted

What evidence does a compiled file leave behind?

Yes it is true. Both .Net and native applications (atleast those compiled by Visual Studio) contain an absolute path to a .pdb (Program Database) file when compiled in debug mode (which is usually the ...
nobody's user avatar
  • 11.5k
3 votes
Accepted

Are Optimization Flags Harmful?

In the bug report you linked, the developer tries to overwrite the password in memory. This changes only the memory contents and has no other side effects. An optimizing compiler may change the code ...
Sjoerd's user avatar
  • 30.4k
3 votes

Are there any type safe languages with deterministic compilers?

There are tools to make builds deterministic. However it is not as simple as picking the correct language and compiler. You also have to eliminate all sources of non-determinism from the build. This ...
AstroDan's user avatar
  • 2,238
3 votes

How do I harden compilers (as suggested by Lynis)?

From a hacker/pentester perspective, I can say that having a compiler on a target machine and/or python/ruby can be very very useful. So I agree with one of the previous answers that removing it from ...
kaidentity's user avatar
  • 2,644
3 votes

Can I get viruses from compiling C# code?

From compiling C# code manually with the compiler, it would take an exploit in the compiler to do more than produce object files and error messages... Not impossible, but not likely either. However, ...
Bruno Rohée's user avatar
  • 5,507
2 votes

Should I compile as root?

There should be no reason to ever compile as the root user. Even if the package will ultimately be run as root, that shouldn't have anything to do with compiling. If you must compile as root to get ...
mikem's user avatar
  • 248
2 votes
Accepted

How to secure batch script with compiler (not compressor) in Windows?

Compiling it will never resolve issues with plaintext passwords or leaking source code. Everything can be decompiled, whatever it's C, .NET, Powershell. Plaintext passwords can be revealed without ...
Aria's user avatar
  • 2,731
2 votes
Accepted

Extreme buffer size consequences

What are the consequences of allocating and then populating an extremely large buffer in C? If a process grows excessively large in virtual memory it can result in thrashing. Can a stack have a ...
julian's user avatar
  • 1,289
2 votes
Accepted

Building software safely for malware-free distribution

It's important to think about what kind of threat you are trying to protect against. Your questions could be taken to imply two different threat levels: A general virus that just injects itself into ...
Anders's user avatar
  • 65.6k
2 votes

Does removing features from a library increase or reduce security risks?

In this case I would consider the custom binary (if any) to be safer, due to the smaller surface of attack. The main problem I would worry about "removing code" would be unintended side-effects, ...
Ángel's user avatar
  • 18.8k
2 votes

Are reproducible builds practically possible on major app stores?

Reproducible builds in an app store are not only possible, but they are standard practice in https://f-droid.org with many apps shipping via the reproducible process that requires that the f-droid.org ...
Hans-Christoph Steiner's user avatar
2 votes

Are reproducible builds practically possible on major app stores?

The answer is no, and that's because most major app stores require signing and generally the signature process used includes a timestamp. Timestamps are inherently non-reproducible. This is the case ...
bk2204's user avatar
  • 9,339
2 votes

Does recompiling a binary from source code make it more secure/obscure?

In general, modern compilers are deterministic. That is, for most sets of options, given the same inputs, they will produce the same outputs. That's why reproducible builds are even possible. ...
bk2204's user avatar
  • 9,339
2 votes

How do I compare the safety of a compiled program with optimization flag?

Compiler options can influence the security of the resulting program in several different ways. Generally speaking, optimization can hurt security. However, this is not a reason to always turn off ...
Gilles 'SO- stop being evil''s user avatar
1 vote

Build and execute code on a sandboxed environment?

As for the infinity loop scenario you can actually: Limit the resources granted per container. Assign the maximum execution time allowed. Optionally kill the container if someone uses 100% of ...
nethero's user avatar
  • 500
1 vote

Avast antivirus virus alarm while programming

Do not turn off your protection. In Avast, just like in most antivirus software, it's possible to add exceptions on a whitelist. Quick Summary Make sure the blocked file or webpage is not ...
Esa Jokinen's user avatar
  • 18.9k
1 vote
Accepted

Compiler Parameters to isolate a C++ program

Providing such restrictions are usually not considered the task of a compiler and it would be very hard to do anyway. Even if only a restricted set of libraries would be available for linking it is ...
Steffen Ullrich's user avatar
1 vote
Accepted

How does GCC's -mmitigate-rop work?

Looks like it was added: https://gcc.gnu.org/ml/gcc-patches/2015-11/msg01773.html I don't know if more was added later: but I think this code just looks for an instruction that can be re-interpreted ...
Douglas Leeder's user avatar
1 vote
Accepted

What are the security trade-offs of using reproducible builds?

Against which types of attacks will it reduce security by preventing compilation techniques based on randomization? You may be thinking about a technique like Address Space Layout Randomization (...
John Deters's user avatar
  • 34.2k

Only top scored, non community-wiki answers of a minimum length are eligible