Skip to content

Commit 4aeae7b

Browse files
committed
CWE-840
1 parent ddf0192 commit 4aeae7b

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

Controller/Controller.cs

+22-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ On enregistre les objets "employé" valides dans un fichier en lecture seule
6464
}
6565
}
6666

67-
return Results.Ok(Newtonsoft.Json.JsonConvert.SerializeObject(new List<object> { File.GetAttributes(ROFile).ToString(), NewId, HaveToBeEmpty.IsNullOrEmpty() }));
67+
return Results.Ok(JsonConvert.SerializeObject(new List<object> { File.GetAttributes(ROFile).ToString(), NewId, HaveToBeEmpty.IsNullOrEmpty() }));
6868
}
6969

7070
public static string VulnerableXmlParser(string Xml)
@@ -147,7 +147,7 @@ Permets aux employés de consulter leurs données personnelles
147147
*/
148148
var Employee = Data.GetEmployees()?.Where(x => Id == x.Id)?.FirstOrDefault();
149149

150-
return Results.Ok(Newtonsoft.Json.JsonConvert.SerializeObject(Employee));
150+
return Results.Ok(JsonConvert.SerializeObject(Employee));
151151
}
152152

153153
public static object VulnerableCmd(string UserStr)
@@ -217,6 +217,26 @@ Permets l'upload de fichier de type SVG
217217
else return Results.Unauthorized();
218218
}
219219

220+
public static async Task<object> VulnerableLogic(int price, int qty, string owner, string client, string activity)
221+
{
222+
/*
223+
Vérifie les champs du formulaire et calcul le prix d'une prestation
224+
*/
225+
int tva = 30;
226+
int FinalPrice;
227+
if (price > 0 && !owner.IsNullOrEmpty() && !client.IsNullOrEmpty() && !activity.IsNullOrEmpty())
228+
{
229+
FinalPrice = price * qty;
230+
FinalPrice += (FinalPrice * tva) / 100;
231+
232+
return Results.Ok(new { FinalPrice = $"{FinalPrice}€" });
233+
234+
}
235+
return Results.StatusCode(400);
236+
237+
}
238+
239+
220240

221241
}
222242
}

Model/Model.cs

+13
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ Login et mots de passe des employés de l'entreprise
2424
public string Passwd { get; set; }
2525
}
2626

27+
public class Invoice
28+
{
29+
/*
30+
Informations de facturation
31+
*/
32+
public int Price { get; set; }
33+
public int Qty { get; set; }
34+
public string Owner { get; set; }
35+
public string Client { get; set; }
36+
public string Activity { get; set; }
37+
}
38+
39+
2740
public class Data
2841
{
2942
public static string GetLogPage()

Program.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@
6767

6868
app.MapGet("/", async (string? lang) => await Task.FromResult(VLAController.VulnerableHelloWorld(HttpUtility.UrlDecode(lang))));
6969

70-
app.MapPost("/Login", [ProducesResponseType(StatusCodes.Status200OK)] async (HttpRequest request, [FromBody] VulnerableWebApplication.VLAModel.Creds login) => await Task.FromResult(VLAIdentity.VulnerableQuery(login.User, login.Passwd)).Result).WithOpenApi();
71-
7270
app.MapGet("/Contract", async (string i) => await Task.FromResult(VLAController.VulnerableXmlParser(HttpUtility.UrlDecode(i)))).WithOpenApi();
7371

7472
app.MapGet("/LocalWebQuery", async (string? i) => await VLAController.VulnerableWebRequest(i)).WithOpenApi();
@@ -79,6 +77,10 @@
7977

8078
app.MapGet("/LocalDNSResolver", async (string i) => await Task.FromResult(VLAController.VulnerableCmd(HttpUtility.UrlDecode(i)))).WithOpenApi();
8179

80+
app.MapPost("/Login", [ProducesResponseType(StatusCodes.Status200OK)] async (HttpRequest request, [FromBody] Creds login) => await Task.FromResult(VLAIdentity.VulnerableQuery(login.User, login.Passwd)).Result).WithOpenApi();
81+
82+
app.MapPost("/Invoice", async (Invoice request) => await Task.FromResult(VLAController.VulnerableLogic(request.Price, request.Qty, request.Owner, request.Client, request.Activity)).Result).WithOpenApi();
83+
8284
app.MapPatch("/Patch", async ([FromHeader(Name="X-Forwarded-For")] string h, [FromForm] IFormFile file) => await VLAController.VulnerableHandleFileUpload(file, h)).DisableAntiforgery().WithOpenApi();
8385

8486
app.UseGraphQL<ISchema>("/Client");

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212

1313

14-
> ⚠️ **Disclaimer** : This repository, together with its tools, is provided by Taisen-Solutions on an "as is" basis. Be aware that this application is highly vulnerable, including remote command and code execution. Use it at your own risk. Taisen-Solutions makes no representations or warranties of any kind, express or implied, as to the operation of the information, content, materials, tools, services and/or products included on the repository. Taisen-Solution disclaims, to the full extent permissible by applicable law, all warranties, express or implied, including but not limited to, implied warranties of merchantability and fitness for a particular purpose.
14+
>⚠️ This repository and its tools are provided "as is." The author(s) make no representations or warranties, express or implied, regarding the operation of the information, content, materials, tools, services, or products included. The author(s) disclaim, to the full extent permissible by law, all warranties, express or implied, including implied warranties of merchantability and fitness for a particular purpose.
1515
1616

17-
## 🎱 Components
17+
## 🎱 Components & Attack Surface
1818

1919
```mermaid
2020
flowchart TD
@@ -24,13 +24,15 @@ flowchart TD
2424
A --> D[Host services]
2525
A --> F[GraphQL]
2626
A --> G[App Services]
27+
A --> H[Memory]
2728
2829
B --> I(*Identities*)
2930
C --> J(*Logs*)
3031
C --> K(*Secrets*)
3132
D --> L(*DNS*)
3233
F --> M(*Sensitive Data*)
3334
G --> O(*Serialized Data*)
35+
H --> P(*Variables and functions*)
3436
```
3537

3638
## 🐞 Vulnerabilities
@@ -60,6 +62,7 @@ flowchart TD
6062
| CWE-787 | Out-of-bounds Write | Easy |
6163
| CWE-798 | Use of Hard-coded Credentials | Easy |
6264
| CWE-829 | Local File Inclusion | Easy |
65+
| CWE-840 | Business Logic Error | Easy |
6366
| CWE-912 | Backdoor | Hard |
6467
| CWE-918 | Server-Side Request Forgery | Medium |
6568
| CWE-1270 | Generation of Incorrect Security Tokens | Medium |

0 commit comments

Comments
 (0)