Hot answers tagged

174 votes
Accepted

How can I export my private key from a Java Keytool keystore?

Use Java keytool to convert from JKS to P12... Export from keytool's proprietary format (called "JKS") to standardized format PKCS #12: keytool -importkeystore \ -srckeystore keystore.jks \ -...
user avatar
125 votes

Why do I hear about so many Java insecurities? Are other languages more secure?

If you use Java like most other programming languages, e.g. to write standalone applications, it is no less secure than other languages and more secure than C or C++ because of no buffer overflows etc....
user avatar
84 votes

Why do I hear about so many Java insecurities? Are other languages more secure?

The security vulnerabilites reported are not about Java (the programming language), which, by virtue of the JVM enforcing memory safety, is actually more robust than languages such as C or C++, where ...
user avatar
  • 1,439
50 votes
Accepted

Is Java secure for the desktop?

Yes - Java desktop and server applications are basically secure. When you run a desktop application - Skype, Picassa, whatever - you give that software full access to your computer. You have to trust ...
user avatar
  • 32.6k
49 votes

Poor error handling source code review

I think you are correct that those issues are more related to code quality rather than security, and none of them are exploitable in any obvious way. I would not call them "vulnerabilities". But ...
user avatar
  • 64.2k
48 votes
Accepted

Am I protected from Log4j vulnerability if I run Java 8u121 or newer?

No, you really need to update log4j. Here is an excerpt from LunaSec's announcement: According to this blog post (see translation), JDK versions greater than 6u211, 7u201, 8u191, and 11.0.1 are not ...
user avatar
  • 2,422
35 votes
Accepted

Client-side BCrypt, store salt and hash separately in MySQL database

The client is the attacker. Walk around your office while chanting that sentence 144 times; be sure to punctuate your diction with a small drum. That way, you will remember it. In your server, you ...
user avatar
  • 168k
35 votes

Sending password from client app to server with Java

Use TLS for the connection to the server. The purpose of securely hashing a password is to make it more difficult to attack if the database is ever stolen. It is not designed to prevent sniffing the ...
user avatar
  • 63.8k
33 votes

Should I worry about remote timing attacks on string comparison?

There are published successes with remote timing attacks. From the document -- "... we can reliably distinguish remote timing differences as low as 20µs." So yes, you should be worried about the ...
user avatar
  • 1,479
32 votes
Accepted

Difference between OpenSSL and keytool

In short, they're both crypto key generation tools, but keytool has the additional feature of manipulating Java's preferred key storage file format, the KeyStore. Java strongly prefers to work with ...
user avatar
  • 71.7k
27 votes
Accepted

Password hashing on frontend or backend?

@John already descriped the passing of the password over the network very well (use HTTPS). To answer your question: Where should I hash them? Frontend or Backend? The backend. If you only hash ...
user avatar
  • 29k
27 votes
Accepted

Should I worry about remote timing attacks on string comparison?

In theory, this is a possible exploit, and if you are in super-paranoia mode, you should assume the answer being "Yes". In every other case, the answer will be: "No.". Although there are published ...
user avatar
  • 4,971
25 votes
Accepted

What are the differences of checking a self-signed certificate vs ignore it?

If it's an official service you are integrating with the provider should really have a valid, publicly signed certificate installed for the sake of security. Assuming that you need to continue on ...
user avatar
  • 3,762
24 votes
Accepted

How are code-branch side channel attacks mitigated on Java?

While you can make some attempt towards constant-time code in general purpose JITed languages like Java, you generally run into some problems: The runtime implementation is, generally, intended to be ...
user avatar
  • 132k
23 votes
Accepted

Is TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 a safe cipher suite to use?

TLS ciphersuite names are structured in such a way that you can tell what algorithms and key sizes are used for each part of the handshake and encrypted session. Let's break this one down and see if ...
user avatar
  • 11.3k
20 votes

Timing attacks in password hash comparisons

The first algorithm is sensitive to timing attacks, while the second looks better (but I don't know for sure if it's vulnerable or not). However, there is a bug with potential security implications in ...
user avatar
  • 64.2k
18 votes
Accepted

Is it more secure to overwrite the value char[] in a String

By fiddling with the internal contents of String instances, you incur the risk of severely breaking your application. The first reason is that String instances are supposed to be immutable, which ...
user avatar
18 votes
Accepted

What is the purpose/role of the "alias" attribute in Java keystore files?

ALIAS To answer your immediate question, the alias field should be a unique string to identify the key entry. This applies to all types such a trusted and intermediate. Documentation Keytool ...
user avatar
  • 3,760
17 votes
Accepted

SSL Newbie : Does HTTPS client also need a certificate?

Depends what you are doing, and what you want to verify. If you are accessing data, and want to be sure that the server which knows the corresponding private key is the one sending you data (e.g. you'...
user avatar
  • 27.2k
16 votes
Accepted

How many bits of entropy does an identifier contain?

The entropy in a session identifier is the entropy of the underlying number source; a PRNG might yield good random words of 32 bits, each of them having 32 bits of entropy (however, as @forrest ...
user avatar
  • 22.5k
16 votes

What are the differences of checking a self-signed certificate vs ignore it?

By importing a known good self-signed certificate where the private key is unique and not compromised, the connection is just as safe as a full global CA PKI signed certificate. Those are after all ...
user avatar
16 votes

Am I protected from Log4j vulnerability if I run Java 8u121 or newer?

https://research.kudelskisecurity.com/2021/12/10/log4shell-critical-severity-apache-log4j-remote-code-execution-being-actively-exploited-cve-2021-44228/ No, you're not safe. Currently we have to ...
user avatar
  • 337
15 votes
Accepted

What is the difference of TrustManager PKIX and SunX509?

From a basic usage point of view, difference is how resulting TrustManagers are initialised, as per Java Cryptography Architecture Oracle Providers Documentation for JDK 8 SunX509: A factory for ...
user avatar
15 votes

Password hashing on frontend or backend?

You are confusing two things: transport security and database security. HTTPS using TLS only protects the transportation of the data from the client to the server. This means an eavesdropper does not ...
user avatar
  • 987
14 votes
Accepted

What is the best way to store password in memory (RAM) in Java?

The general guidance is to use a char[], which while not foolproof, will allow you to overwrite the characters in the password once you're done with them, something that is not possible with strings, ...
user avatar
  • 35.5k
14 votes

Should I worry about remote timing attacks on string comparison?

Store a good cryptographic hash of the secret on the server (i.e. treat it like a password). Your comparison then would be to take the hash of the string the client sends you, and compare the hashes. ...
user avatar
  • 3,845
14 votes
Accepted

Why do I need to add intermediate CA certificates to JVM's cacerts file?

The problem you describe happens usually if the server only sends its leaf certificate and does not add all the chain certificates needed to build the trust chain to the root CA. Unfortunately this is ...
user avatar
13 votes
Accepted

ECDSA: Why do ssh-keygen and Java generated public keys have different sizes?

Sizes are different because the formats are different. The strings you show are both binary values encoded in Base64. In all this message I talk about the binary values, i.e. I suppose that you first ...
user avatar
12 votes

Can you write OS-related virus using high level languages like Python

Yes, malware exists in all sorts of languages. Often, though, some of the most critical fiddly bits of many exploits are written not in C or C++, but rather directly in machine code, carefully ...
user avatar
  • 82k
12 votes

Preventing Server-Side Request Forgeries in Java

This is the code I'm currently using: if(!url.getProtocol().startsWith("http")) throw new Exception(); InetAddress inetAddress = InetAddress.getByName(url.getHost()); if(inetAddress....
user avatar
  • 32.6k

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