Information Security


Scope

Cyber security is all about defending against unwanted data controls. Or more precisely enforcing Confidentiality, Integrity and data Availability within a system.

Hacking is fundamentally about data control, controlling the data on a webpage, in a database, cookie or data sitting on a webserver out there somewhere in the clouds.

For a hacker controlling the data means compromising:

Kerckhoff’s Principle

Kerckhoff’s principle is the concept that a Cryptographic system should be designed to be secure, even if all its details, except for the key, are publicly known. Kerckhoff’s principle is similar to Shannon’s maxim.

Shannon’s Maxim

“the enemy knows the system”

 .-----------.     secret channel         .-----------.
 |           |----------------------------|           |
 |       k---|----------> k --------------|--->k      |
 |       |   |----------------------------|    |      |
 |       v   |                            |    v      |
 |     +---+ |----------------------------|  +---+    |
 | m-->| E |-|----------> c --------------|->| D |    |
 |     +---+ |----------------------------|  +---+    |
 '-----------'      public channel        '-----------'
    Sender                                  Receiver
--------------------------------------------------------
  Figure 1: Shannon’s model of secret communication

One Time Pad

According to Shannon and his Information Theory_ perfect confidentiality is possible and can be achieved using a simple encryption algorithm called the One Time Pad. Though the One Time Pad is impractical for most applications and that according to Information Theory nothing more practical can be secure.

The One Time Pad views messages as sequences of symbols (bits) and encrypts them by a simple mixing of each symbol with a corresponding symbol extracted from the key. However, it is crucial for the security of the scheme to use a random key of the same length as the message to encrypt. With any shorter key, the One Time pad degenerates into a variation of the Vigenere cipher and becomes very weak. Transmitting very long keys securely is rarely easier than directly transmitting messages securely. Moreover, the One Time Pad is error prone and any key reuse dooms the security of the corresponding messages. In practice, a user would expect to use a relatively short key for the transmission of long messages. Using Information Theory, Shannon showed that this is not possible. Indeed, a powerful enough cryptanalyst can always try to decrypt the transmitted message using all possible keys. The only key that yields a meaningful message is the correct one.

Attack Model

In order to secure a system, one should be aware of the capabilities of the attackers, this is more important than trying to consider all the possible specific attacks/exploits that can be performed on the system. Once you have a detailed list of the capabilities of an attacker you can proceed to restrict these capabilities, this list of capabilities is the systems Attack Model.

Likewise if an attacker is trying to exploit the system they should be aware of the attack model (their capabilities) and take advantage of the capabilities that are unrestricted.

Provable Security

In security, and especially in cryptography, precise definitions and proofs of security, or at least extensive, clear analysis, are necessary to ensure that a system is secure against arbitrary attacker strategies. This approach is usually referred to as provable security. As a penetration tester, you should always ask yourself what proofs that this system/scheme is secure?

That said, one has to be very careful to understand the limitations and pitfalls of proofs, discussed in a series of papers by Koblitz and Menezes. Proofs of security often involve simplifications and assumptions, even simplitying ‘assumptions’ known to be incorrect.

A proof of security is a powerful tool, but, like other power tools, should always be used carefully and correctly. Namely, we must fully understand the definitions, assumptions and simplifications, and never assume additional properties or applicability to scenarios where the assumptions do not hold.

Risk and costs-benefit analysis

Security managers have to consider the costs of deploying security mechanisms, against the probability of an attack and the expected damages from possible attacks, if the mechanisms are not deployed. Risk analysis is an attempt to estimate the probabilities of occurrence of different attacks, and of the attacks being successful; and cost-benefit analysis uses these values, as well as the costs of deploying different security mechanisms, to decide which security mechanisms are worth deploying.

Attack Avenues

A hacker needs to find avenues to connect and enter the system, through these avenues the hacker can get the system to run and hopefully get it to crush and burn.

Naive systems fail to consider all that can pass through those doorways, the same door that fits the angel also fits the demon.

It is good practice to decompose a system or sub-system to its doorways and analyze the angels (expected input) and demons (hacker input).

Avenue Discovery

Network Server Ports

The first avenue for internet connected systems is usually the open ports of the system, which allow remote computers to connect to it. A usefull tool for discovering open ports on a internet connected system is:

Below are some common avenues that can be connected and their ports:

Telnet

FTP

Cryptanalysis Principles

Software Supply Chain

This document gives an overview of the core software infrastructure that https://emancipa.tech depends on.

This document gives an overview of the core software infrastructure that emancipa.tech depends on.

You can find allot of brilliant code on the internet, skillful programmers pushing computers to the limits. Some code is written as a form of self expression – art or simply to make a statement in the fabric of consciousness.

The point is not all code is meant to be dependent on especially for safety critical applications. Dependencies should be picked with great care. This is an important principle for cyber-security. A rigorous analysis of your dependencies can be the best protection against supply-chain attacks. This also means that dependencies should be simple and minimal with a relatively small code surface to make it possible to analyze/audit. Sometimes this means that we will have to rewrite some components instead of depending on software that does not fit our methodology.

Choosing Dependencies

The general methodology we use to decide to depend on a piece of software:

  1. License : We depend on
  2. Age: The software should not be too old, because it might not be supported by modern platforms or have received security updates. The software should also not be too new and without enough running in the wild.
  3. Code quality & Auditing: We prefer to use audited code, the auditor should preferably be a 3rd party and not related to the original author. This is particularly important for cryptography software. The code should be of high quality and integrity.
  4. Test Suite_: The software should be well tested with unit tests, end-to-end tests and extensive fuzzing. It also helps if there is benchmarks comparing it to alternatives.
  5. Documentation: Well documented software is preferred, software with clear APIs and interfaces, it is also plus if the code itself is well commented.
  6. Developer: Is the project sustainable, are there maintainers and are they well funded or even motivated to keep the software up to date and stable.
  7. Ecosystem: Software should have a vibrant community and enough resources (docs, blog, vids, example code). It also helps if the software can be easily integrated with other software especially with our other dependencies.
  8. Minimalism: Software should be simple, clear, frugal, modular and correct. see unix philosophy and suckless.

Rust

Rust is a modern programming language with built in features for safe systems programming. Rust is designed to eliminate classes of software bugs/vulnerabilities that have been historically difficult to prevent.

Rust is also fast and low-level like C/C++ but drastically safer and more ergonomic to write, making it an ideal candidate for high performance and secure systems software.

Classes of Bugs Stopped by Rust

//TODO: - https://corrode.dev/blog/bugs-rust-wont-catch/ - https://news.ycombinator.com/item?id=47943499

Specification and Formal Verification

Rust reached v1.0 in 2015, so it is a relatively young language so at the time of this writing Rust is not yet formally verified, no specification exists and the Rust reference is incomplete. None the less, Rust is used being used by allot of professional companies from Google, Microsoft, Facebook and lots of crypto-currencies all of them use Rust for what is promises to bring to the table: safe, fast systems programming.

Rust is well tested at this point just not formally verified and specified making it unable to be used for safety-critical environments that need a language to be formally specified.

More info about ongoing Rust R&D in formal verification tooling:

Also checkout this wonderful book High Assurance Rust, which is a great inspiration for this document and some of the methodologies used at https://emancipa.tech/

Password Hashing

Why hash?

There is always a possibility of our servers getting hacked, and if that happens we don’t want the users passwords to be leaked – this will allow the attacker to gain access to the users resources. Some users also use the same password across many services, we don’t want our servers to be the root cause of a chain of breaches.

A cool way to prevent this is by obfuscating the users password with a hash function.

There are lots of hash functions that can be used, but most of these will be a bad idea to use. For example if you use SHA-256 or other computationally cheap functions (hash function without a work factor parameter), they are vulnerable to rainbow table attacks. Bruteforce is also possible if the password length is short/known, asic miners can generate 100 TeraHashes PER Second.

The server can increase the passwords entropy by concatenating it with a random string aka the salt. Users can also protect themselves by using longer passwords.

The best method to use against plaintext password leaks and rainbow table attacks is to use a Password Hash Function. Which is a hash function specially designed to be slow/expensive to compute even on specialized hardware.

The scrypt hash function uses large amounts of memory when hashing making it expensive to scale to the point of reasonable bruteforce attacks. Secure against hardware brute-force attacks.

A number of cryptocurrencies use scrypt for proof of work.

Created by Colin Percival of https://en.wikipedia.org/wiki/Tarsnap

The Argon2d function is designed to resist GPU cracking attacks. Secure against hardware brute-force attacks.

It is the winner of Password Hashing Competition.

Bcrypt

Bcrypt is based on the blowfish cipher.

Vulnerable against hardware brute-force attacks.

PBKDF2

PBKDF2 is an key derivation function with a sliding computational cost to reduce bruteforce search.

Vulnerable against hardware brute-force attacks.

Conclusion

A cool way to prevent password leaks is by obfuscating them with a password hash functions which offer additional security against bruteforce from specialized hardware such as asics. If password hash functions are used and implemented correctly even the administrators of the server will not be able to read the users passwords especially if the server is open source and the users can audit the code for themselves.

References


[home] | Emancipation through technology |