• No results found

Lab_13_project_and_fixes.pdf

N/A
N/A
Protected

Academic year: 2020

Share "Lab_13_project_and_fixes.pdf"

Copied!
22
0
0

Loading.... (view fulltext now)

Full text

(1)

Security Testing

Laboratory

Emanuele Viglianisi

Security&Trust Research Unit

Fondazione Bruno Kessler

(2)

Agenda

Project Recap

Selenium example on the project

Fixes

(3)
(4)

Project tasks

A software company is developing a new website

Inventory-Management-System. This software has to be sold

to different companies to manage their inventory.

The software companies wants to ensure their software has not XSS flaws and decided to hire you as a Security expert.

They expect a report which describes the procedure you have followed, the test cases you run to verify the presence of the

(5)

What to do (1)

1. Detect XSS vulnerabilities using Pixy.

2. Classify TP and FP:

a. For TP: manually elaborate the

proof-of-concept injections, then write

an automated test case (using selenium)

to assert the presence of the

vulnerabilities.

(6)

What to do (2)

1. Fix the vulnerabilities on the source code.

2. Using the automated test case you wrote,

assert that your fixes are effective in

(7)

FAQ

What is the format of the report? How many

pages should the report have?

Your customer asked you for a report.

They say nothing about the content, the

format and the number of pages.

(8)

Test cases

1. Open the image generated by Pixy

2. Try to manually exploit the vulnerability

3. Try to replicate the manual steps using selenium

The test has to pass (green) if you were able to exploit the XSS vulnerability (you see the code you injected).

Note. Use the pixy’s name as class name:

if xss_dashboard.php_10_min → class

(9)

Attack vector

You have to assert that the XSS attack has been performed.

How:

- assert the presence of injected HTML

- Is there any link with attack.com in href attribute? - Is there any h1 node with this text “attack”?

- ...

- assert the presence of javascript

(10)

How to fix? (1)

Use

htmlspecialchars

or

htmlentities

example:

<?php

$str = "A 'quote' is <b>bold</b>";

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;

echo htmlentities($str);

// Outputs: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;

echo htmlentities($str, ENT_QUOTES);

(11)

How to fix? (2)

Use intval, floatval, boolval

https://www.php.net/manual/en/function.int

val.php

<?php

echo intval(42); // 42

echo intval(4.2); // 4

echo intval('42'); // 42

echo intval('+42'); // 42

(12)

Fix (1)

Go back to the source code inside

/opt/lampp/htdocs/inventory-management-system

and fix the vulnerability on the target file

(13)

Fix (2)

Go back on your Selenium test case.

- Re-run the test

- It should fail (red), since the vulnerability has

been fixed

(14)

Corner cases (1)

Some corner case with Selenium:

1) Pop-up dialogs 2) Upload of files

(15)

Corner cases (2)

Pop-up dialogs:

1. Click to open the dialog 2. Thread.sleep(X)

3. Locate the elements (eg. findElement)

(16)

Corner cases (3)

Upload of files

For example, to create a new product

- Make sure the form is visible

- Don't click on the browse button, it will trigger an OS level dialogue box and effectively stop your test dead. Instead you can use:

driver.findElement(By.id("myUploadElement")).sendKeys("<absolutePathToMyFile>"

);

- myUploadElement is the id of that element (button in this case) and in sendKeys you have to

(17)

Corner cases (4)

Upload of files

- But if you use an absolute path like this /john/images/mypicture.png I won’t

be able to run the test you did.

- Put your file inside src/main/resources

Read the File from the resource directory and evaluate its absolute path realtime.

URL res = getClass().getClassLoader().getResource("abc.txt");

File file = Paths.get(res.toURI()).toFile();

(18)

Corner cases (5)

Dealing with inputs (dropdown menu)

Select elm = new Select(driver.findElement(By.id("productStatus")));

(19)

Corner cases (6)

Bypass input restriction

webdriver.executeScript("document.getElementById('productStatus').setAttribute('val ue', 'new value for element')");

or

WebElement inputField = driver.findElement(By.Id('productStatus'));

(20)

Corner cases (7)

webdriver.executeScript("your_javascript_code_here", arg1, arg2, ...);

Powerful tool:

- You can edit manually elements - You can send XHR requests

Reference:

(21)

When to deliver the project?

Deliver the project at least 1 week before

the written exam.

Use the form

(22)
Use or https://selenium.dev/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html https://forms.gle/At1xseAQKf4qNRLF9

References

Related documents

DSMEs tend to progress through a distinctive life cycle. Like all other SMEs, these firms normally begin by raising funds from family, friends, and close associates,

The Trust is satisfied that the information requested would be likely to prejudice the commercial interests of the company concerned, and in turn the Trust, however the exemption

Examples of alerting systems include Alertmaster, Simplicity, and Sonic Alert, and can only be purchased from vendors who specialize in products for people who are deaf or hard

Community Meeting London 2011 European Data Protection Legislation.  EU Directives are not legally binding for citizens

Measures to decrease the number of VRU casualties in traffic are dedicated to influence driver and road users to show more safe behaviour, to make infrastructure more forgiving

∆ W (or ∆ε ), the permanent per-cycle damage in the material, not only reflects the effect of temperature change ∆ T , but also the effects of package geometry (e.g. solder

The factors in- clude: uncertainty to identify regulated and unregulated farms of NMA, settings of regulation timing, other nutrient regulation by-laws that may affect dairy

This study aimed to analyze the performance of all of Palestinian Commercial Banks for the year 2014 using CAMEL approach, to evaluate Palestinian Banks’ capital adequacy,