Skip to content

Conversation

hi-unc1e
Copy link

@hi-unc1e hi-unc1e commented May 27, 2021

Hi, guys

While I using testlink I had noticed that an arbitrary open redirect is not validating properly which may lead to credentials stolen of the user (self-xss).

  • Risk: Medium
  • Tested version: 1.9.20
  • Environent: Windows10+ Chrome90.0.4430.212
  • Credit:
    image

Personally I prefer to split them into 2 vulns, Here's what i found

0x01 the vulnerable regex -> Unvalidated Redirects and Forward

Related code lies in login.php#371 , which is shown as follows
image

the regex-expression /linkto.php/ stands for the combination of [linkto]{1} + [\w]{1} + [php]{1}, in which . can be replaced by any signle character, so as a consequence.
These input could pass the validation, and reflected in the HTTP response when a user succeed in logining.

destination=ANYSITE/linkto1php

image

So the mediation may be like /^linkto\.php$/ , according to what your need.

What happened next may elevate this risk to a High-Level vuln.

0x02 Improper XSS validation

While deeply analysing the function of redirect(), i noticed an odd implementation.

$safeUrl = addslashes($url);

image

ONLY addslashes is used, which is SURELY NOT ENOUGH and VULNERABLE to XSS attack.
Which means if I craft a XSS payload in the URL, it could execute any Javascript Code in victim's browser, certainly after he's logged in.
image

Putting together

So the senario is:

  1. Craft a URL, for example: http://testlink/login.php?viewer=123&destination=</script>linkto.php<script>alert(/xss/);//
  2. Send it to a victim, the victim open that link
  3. The victim logged with correct credentials
  4. XSS attack is triggered, an attacker could steal the victim's valid cookie or craft a phishing page to the victim depends on different purpose.
  5. Here is the PoC of this vuln ( You can see that Javascipt-script is executed on victim's browser. )
    image

Mediation

For 0x01, you should validate the $destination properly according to Unvalidated_Redirects_and_Forwards_Cheat_Sheet

For 0x02, you should escape the user-input data ( htmlspecialchars() for instance ) properly, according to Cross_Site_Scripting_Prevention_Cheat_Sheet.html

leif81 and others added 25 commits February 24, 2021 21:24
The current year is probably a better year than almost a decade ago ;)
…w link implementation between requirements and test cases (#300)

* fix: #0009038: Make the 'Requirements based report' compliant with new link implementation between requirements and test cases

Due to 1.9.18 changes concerning links between requirements and test cases, we change the report to work at version level.

* fix: #0009038: Exclude of the report requirements with no linked (non obsolete) Test Case
…ix (#301)

Due to 1.9.18 changes concerning links between requirements and test cases, we update and add methods to be able to retrieve a requirements coverage matrix.

1- getRequirements - retrieve all requirements
2- getRequirement - for a requirement, get a version (the last one by default)
3- getReqCoverage - for a requirement version, get the test cases linked with it
I think the function getIssueTrackerSystem has two issues, which I hope to correct with this request:
1. the return value of authenticate() is not checked, therefore even with wrong dev key the issue tracker data is sent out, leaking e.g. credentials for the issue tracker to anyone
2. a check if the user has the permission to view issue tracker info was missing
#207)

* TICKET 0008715: Add a method to retrieve all requirements linked to a given test case

Change-Id: Ib9c417f572306dbff9fbe31b3a0a8e32c7c03704

* Add rights check for getTestCaseRequirements

* Add PHP tests for clientGetTestCaseRequirements

* Review the method to retrieve requirements to be compliant with the new way to link TC and requirements

Co-authored-by: atisne <[email protected]>
…en linking with an existing issue (#310)

We can define a template for an execution note ($tlCfg->execution_template->notes) to automatically populate some contextual information.
This template is used when creating a new external issue from a Testlink bug (using the 'Create issue' icon).
But it is not used when we want to link a Testlink bug to an existing external issue (using the 'Link existent issue' icon).

We now also use this template in the case of linking.
…rsion ID as inputs. (#312)

When we use the option getPrefix, the way to retrieve the project prefix is not compliant
with all these kind of inputs.
It may be useful to add some contextual information concerning the test case used
in the execution note template. We add the patterns %%TCNAME%% (test case name)
and %%TCEXTID%% (prefixed test case external ID) that can be substituted in the
note template.
@hi-unc1e hi-unc1e changed the base branch from testlink_1_9 to master May 27, 2021 06:56
@hi-unc1e hi-unc1e changed the title OpenRedirect in login.php OpenRedirect leads to XSS attack in login.php May 27, 2021
@fmancardi
Copy link
Contributor

master branch is not the right one
the right branch is testlink_1_9_20_fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants