Home

Home / Web App Security / OWASP / WebGoat

Cryptographic Failures

· Matthew Crum

Introduction

WebGoat is a deliberately insecure web application maintained by OWASP designed to teach web application security lessons. More information including how to download and run WebGoat can be found here on the projects GitHub. This is post nine of a series where I will be doing WebGoats challenges to further my understanding of the OWASP Top 10 and web application security as a whole. I have started from the number 10 and am working my way backwards to number 1.


#2 Cryptographic Failures

If web applications don’t protect sensitive data such as financial information and passwords, attackers can gain access to that data and sell or utilize it for nefarious purposes. Data exposure risk can be minimized by encrypting all sensitive data. The first thing is to determine the protection needs of data in transit and at rest. Passwords, credit card numbers, health records, personal information, and business secrets require extra protection, mainly if that data falls under privacy laws. For all such data there are several things to take into consideration:

To prevent cryptographic failures the following should be done at a minimum:


Encoding

Encoding is not really cryptography, but it is used a lot in all kinds of standards around cryptographic functions. It is a process of converting data from one form to another according to a specific set of rules or standarads. Encoding does not invovle any deliberate attempt to conceal the information or make it unintelligible to unauthorized users.

Encoding is a general term used for various data transformation processes some of which include:


Encryption Vs Hashing

Encryption is a specific process within the cryptography. It invovles converting plaintext data into ciphertext using an encryption algorithm and a secret key. The purpose of encryption is to protect the confidentiality of data by making it unreadable to unauthorized parties. The ciphertext can only be converted back into plaintext by using the corresponding decryption algorithm and key.

Common Encryption Algorithms include:

Hashing is a one-way function that takes an input and produces a fixed-size string of characters, which is typically a hash value or digest. The resulting vlue is uniq to the input data, meaning even a small change in the input will produce a significantly different hash value. Unlike encryption which can be reversed with a secret key hashing is designed to be irreversible. Hash functions are commonly used for data itegrity verification, password storage, digital signatures and other cryptographic applications.

Common Hahsing Algorithms include:


WebGoat Challenges

Challenge 1

Basic Authentication

challenge1

For this challenge I just need to decode the base64 string provided in the challenge. This can be done right from the terminal.

echo "Y3J1bWJsZXM6YWRtaW4=" | base64 –d

decode

complete

Challenge 2

XOR Decoding

challenge2

For this one I used an online decoding tool rather than trying to guess the cryptographic key used here XOR Decoder

decoding tool

complete2

Challenge 3

Plain Hashing

challenge3

For this one I had over to crackstation to identify the hashing algorithms and crack the hashes for the challenge.

cracked

complete3

Challenge 5

RAW Signatures

challenge 4

First I need to take the provided private key and save it as a file. From there I can run that file against the openssl command to try to obtain the Modulus.

openssl rsa -in private_key.pem -noout –modulus

openssl is the command line tool being used, rsa specifies that an RSA key will be invovled, -in specifies that the next parameter will be a filename for the command to take as input, private_key.pem is what I named the file. -noout specifies no output other than the desired information should be displayed, -modulus specifies that output should be the modulus of the RSA key.

The result is a pretty long string.

Modulus=C821C0494F8B0720404C50E9E124F4B080ED1DEC2BF3B3D93F533D020DD368FFD10B843955B79413ABBEE91CD0D659847A0688CAFF8C58677177F4B3B8F43438D46FE365CCCE053DD70601207E53A67BB98E274472D29303504EFF56D59CB5E36664C5EDA51F6C05FEB95B37BCEAF730FDDBAE55D42111D298EB89F01944702DF0598BDEFE9B33735F3D3B25EC65373B3425F5A64C0E67050F832EC82CAC8D5D113B5915F04B86A856AEE35A8588B3EF703BD59C5201164BEAA536DEF65B52D2FC0B13FA40E89791910725365989DD322774BD707407F52464A88516A762ACA94209B5D84EB63F4C3A11FDC2B5F59BB1D07F77BBC23F8E2F82B66BFABE5670DB

key file

modulus crack

For the next step I need to take the Modulus output and generate a digital signature that then gets base64 encoded.

echo "C821C0494F8B0720404C50E9E124F4B080ED1DEC2BF3B3D93F533D020DD368FFD10B843955B79413ABBEE91CD0D659847A0688CAFF8C58677177F4B3B8F43438D46FE365CCCE053DD70601207E53A67BB98E274472D29303504EFF56D59CB5E36664C5EDA51F6C05FEB95B37BCEAF730FDDBAE55D42111D298EB89F01944702DF0598BDEFE9B33735F3D3B25EC65373B3425F5A64C0E67050F832EC82CAC8D5D113B5915F04B86A856AEE35A8588B3EF703BD59C5201164BEAA536DEF65B52D2FC0B13FA40E89791910725365989DD322774BD707407F52464A88516A762ACA94209B5D84EB63F4C3A11FDC2B5F59BB1D07F77BBC23F8E2F82B66BFABE5670DB" | xxd -r -p | openssl dgst -sha256 -sign private_key.pem | base64

The first part echo " " | takes my modulus from earlier and pipes it into the next command xxd -r -p which takes the hexadecimal string and converts it back to binary data, that is then piped into openssl dgst -sha256 -sign private_key.pem where OpenSSL will perform a SHA-256 hash of the data using the RSA private key supplied by the challenge, creating the digital signature. Finally that digital signature is piped into a base64 command to format it correctly for the challenge. Which outputs the following:

SenOVqUJG5uk4/QsIChkM3mOFS/ndk1eyXTAh/7iVn0GxEd+SSLtvU1Uy1+W2VdBtGRrs+akQwYp1Hc5boG75HZaZhNWMgnQRmKDKKOguCBIvXEL7bRJMJXz7OUThEtziBB9TxNlW6+8J1sum6Aq45F/q7CdDWpJNfT8ohfwNlynxwiIvMIXDq8sgISWs1TBlHstC3AIzPnCP0896OHdA3J1F+qfia/4I53kpm6zllvx4A2cN3VW/PhmC047lm63jna07avNPzo29P19EUrebIBGppsv27HS3iAV6SH7Y4uXKqi/g7KJFzpQwua1flDNolLAisc5ZaGJBblzOTs+pw==

signature

Unfortunately this didn’t solve the challenge since the modulus wasn’t correct. I tried formatting it a couple of different ways but that didn’t seem to be the problem. I’ve concluded I’ll have to learn more about digital signatures before I’m actually able to solve this challenge.

failed 4