Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .npmrc

This file was deleted.

237 changes: 233 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,235 @@
# CheapCryptoBank online application
# WE built this to be purposedly vulnerable
The given code appears to be a simple login page written using React and Material-UI. However, there are a few potential vulnerabilities and bugs that can be addressed:

This project builds the CheapCryptoBankApp which you can find at https://app.cheapcryptobank.com
1. Lack of client-side validation: The code does not perform any client-side validation to ensure that the user has entered valid data into the login fields. This leaves the application open to input validation attacks, such as SQL injection or cross-site scripting (XSS).
Solution: Add client-side validation to ensure that the user enters only valid data.

There are multiple components to this app.
2. Lack of server-side validation: The code does not perform any server-side validation to ensure that the user has entered valid data into the login fields. This leaves the application open to input validation attacks, such as SQL injection or cross-site scripting (XSS).
Solution: Add server-side validation to ensure that the user enters only valid data.

3. Unsecured password field: The password field is not secured, which means that anyone can view the entered password by looking over the user's shoulder or through a network packet sniffing attack.
Solution: Use the "type=password" attribute to secure the password field and hide the entered password.

4. Unprotected data transfer: The data transfer between the client and server is not encrypted, which means that anyone can intercept and view the data in transit, including the user's login credentials.
Solution: Use HTTPS to encrypt the data transfer between the client and server.

5. Lack of password complexity requirements: The code does not enforce any password complexity requirements, which leaves the application open to brute-force attacks.
Solution: Add password complexity requirements, such as requiring a minimum password length, requiring the use of special characters, or requiring a combination of uppercase and lowercase letters.

Here is the updated code with the solutions for the above-mentioned vulnerabilities and bugs:

````
```
import React, { useState } from "react";
import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import CssBaseline from "@material-ui/core/CssBaseline";
import TextField from "@material-ui/core/TextField";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import Checkbox from "@material-ui/core/Checkbox";
import Link from "@material-ui/core/Link";
import { Grid, Paper } from "@material-ui/core/";
import Box from "@material-ui/core/Box";
import LockOutlinedIcon from "@material-ui/icons/LockOutlined";
import Typography from "@material-ui/core/Typography";
import { makeStyles } from "@material-ui/core/styles";
import Container from "@material-ui/core/Container";
import image from "../images/NiftyBank.png";

function validateEmail(email) {
const re = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return re.test(String(email).toLowerCase());
}

function validatePassword(password) {
const re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/;
return re.test(password);
}

function handleSubmit(e, email, password) {
e.preventDefault();

if (!validateEmail(email)) {
alert("Please enter a valid email address");
return;
}

if (!validatePassword(password)) {
alert(
"Please enter a password that is at least 8 characters long and contains a combination of uppercase and lowercase letters, numbers, and special characters"
);
return;
}

// Send login request to server using HTTPS
fetch("https://example.com/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, password }),
})
.then((response) => {
if (!response.ok) {
throw
```
````

Additionally, this code contains several vulnerabilities that could potentially expose sensitive information or compromise the security of the application. These vulnerabilities include:

1. Hardcoded .npmrc authtoken
2. HSTS not enabled
3. No detect CSP policy
4. No security.txt file
5. Missing referrer policy
6. Missing security headers

It is important to address these vulnerabilities and implement proper security measures to ensure the safety and integrity of the application.

In addition to the vulnerabilities present in the code itself, the repository has a total of 72 code vulnerabilities that have been identified, including several critical ones. Some of the notable vulnerabilities include:

1. Improper Neutralization of Special Elements used in a Command in Shell-quote: vulnerability
2. Prototype Pollution in minimist
3. Vulnerability in property-expr (effects N/A)
4. React-dev-utils vulnerability
5. Prototype Pollution in property-expr (effects yup)
6. Prototype Pollution in url-parse and json-schema (effects jsprim)
7. Prototype pollution in merge-deep
8. Vulnerability in json-schema (effects N/A)
9. Exposure of Sensitive Information in eventsource
10. Vulnerability in loader-utils and postcss (effects react-scripts)
11. Vulnerability in watchpack-chokidar2 (effects N/A)
12. Prototype Pollution in JSON5 via Parse Method
13. Terser insecure use of regular expressions leads to ReDoS
14. Vulnerability in minimatch (effects react-dev-utils)
15. Prototype Pollution in immer (effects react-dev-utils)

It is essential to address all of these vulnerabilities and ensure that the code is secure before deploying it to a production environment.

The code below could benefit from some UI enhancements to make it more visually appealing and user-friendly. In order to achieve this, I provide sample code to improve the user interface, which includes the code below:

````
```
import React from "react";
import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import CssBaseline from "@material-ui/core/CssBaseline";
import TextField from "@material-ui/core/TextField";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import Checkbox from "@material-ui/core/Checkbox";
import Link from "@material-ui/core/Link";
import { Grid, Paper } from "@material-ui/core/";
import Box from "@material-ui/core/Box";
import LockOutlinedIcon from "@material-ui/icons/LockOutlined";
import Typography from "@material-ui/core/Typography";
import { makeStyles } from "@material-ui/core/styles";
import Container from "@material-ui/core/Container";
import image from "../images/NiftyBank.png";

const useStyles = makeStyles((theme) => ({
paper: {
marginTop: theme.spacing(8),
display: "flex",
flexDirection: "column",
alignItems: "center",
padding: "20px",
borderRadius: "10px",
boxShadow: "0 0 10px 0 rgba(0,0,0,.2)",
},
img: {
width: "150px",
height: "150px",
marginBottom: "20px",
},
avatar: {
margin: theme.spacing(1),
backgroundColor: theme.palette.secondary.main,
},
form: {
width: "100%",
marginTop: theme.spacing(1),
},
submit: {
margin: theme.spacing(3, 0, 2),
},
}));

export default function SignIn() {
const classes = useStyles();

return (
<Container component="main" maxWidth="xs">
<CssBaseline />
<Paper className={classes.paper}>
<Avatar className={classes.avatar}>
<LockOutlinedIcon />
</Avatar>
<Typography component="h1" variant="h5">
Sign in
</Typography>
<form className={classes.form} noValidate>
<TextField
variant="outlined"
margin="normal"
required
fullWidth
id="email"
label="Email Address"
name="email"
autoComplete="email"
autoFocus
/>
<TextField
variant="outlined"
margin="normal"
required
fullWidth
name="password"
label="Password"
type="password"
id="password"
autoComplete="current-password"
/>
<FormControlLabel
control={<Checkbox value="remember" color="primary" />}
label="Remember me"
/>
<Button
type="submit"
fullWidth
variant="contained"
color="primary"
className={classes.submit}
>
Sign In
</Button>
<Grid container>
<Grid item xs>
<Link href="#" variant="body2">
Forgot password?
</Link>
</Grid>
<Grid item>
<Link href="#" variant="body2">
{"Don't have an account? Sign Up"}
</Link>
</Grid>
</Grid>
</form>
</Paper>
<Box mt={8}>
<Typography variant="body2" color="textSecondary" align="center">
{"Copyright © "}
<Link color="inherit" href="https://material-ui.com/">
Niftybank
</Link>{" "}
{new Date().getFullYear()}
{"."}
</Typography>
</Box>
</Container>
);
}
```
````

Thank you for the opportunity to apply for the Octernships program through GitHub, and for the chance to complete the Securestack task assignment. I have thoroughly enjoyed the experience of analyzing the provided code and identifying potential security vulnerabilities and UI enhancements. I am eager to further develop my skills and knowledge in software development, and I am excited about the possibility of being selected for the program. Thank you again for your consideration, and I hope to hear from you soon.
7 changes: 0 additions & 7 deletions app.config

This file was deleted.

Loading