Git Product home page Git Product logo

coldfront's People

Contributors

aebruno avatar artlogic avatar bhatiadheeraj avatar dependabot[bot] avatar dmr-x avatar dsajdak avatar mkzia avatar quoding avatar zooley avatar

Watchers

 avatar

coldfront's Issues

Security issue: client-provided values trusted for POST data - publication add via search

Originally mentioned by @dmr-x in context of #4

Problem summary

The Add Publications feature (via search*) trusts the client's POST data from the search-results form. A slightly technically inclined user may change the data (publication title, author, etc.) in the form, and that altered data will simply be trusted and added to the database.

In the worst case, since the doi (or other id) forms part of a URL, this user would be able to change the URL used for the publication, potentially affecting all users in the project or others (admin, staff) that click on it.
doi.org for example provides a service that automatically redirects the browser to the publication's target page. A malicious user could create a doi pointing to a malicious page (or exploit an existing doi's target), thereby launching an attack; such as phishing, a XSS-vulnerable page, a browser exploit, etc.

This is admittedly unlikely, and adding a publication to a given project is already gated by user permission.

*NOTE: this is a pre-existing problem, and not a result of the feature in PR #4.

Problem technical

Buggy code snippet:

def post(self, request, *args, **kwargs):
pubs = eval(request.POST.get('pubs'))
project_pk = self.kwargs.get('project_pk')
project_obj = get_object_or_404(Project, pk=project_pk)
formset = formset_factory(PublicationResultForm, max_num=len(pubs))
formset = formset(request.POST, initial=pubs, prefix='pubform')
publications_added = 0
publications_skipped = []
if formset.is_valid():
for form in formset:
form_data = form.cleaned_data
source_obj = PublicationSource.objects.get(
pk=form_data.get('source_pk'))
publication_obj, created = Publication.objects.get_or_create(
project=project_obj,
title=form_data.get('title'),
author=form_data.get('author'),
year=form_data.get('year'),
unique_id=form_data.get('unique_id'),
source=source_obj
)

Simplest fix

  1. Make use of commits* from PR #4 development.
  2. Refactor search and search-results views to retrieve remote publication data twice: once for the search, and again after the client identifies which publication(s) to add.

Estimate to fix:
4 hours

*relevant commits:
371fa1c
f43afdf
7f2bf18
07d6b2f
9c8ae3f

Publications sharing project, title, and year cannot be deleted

Originally posted by @dmr-x in #4 (comment) - text modified for context

Problem summary

POST /publication/project/{project}/delete-publications/ fails for almost-duplicate publications.
The Delete Publications feature does not make use of guaranteed uniqueness in selecting publications to delete, but rather pulls them by Title and Year.

Additionally, the view showing these publications does not present enough detail to the user to know the difference between them.

Problem technical

Buggy code snippet:

publication_obj = Publication.objects.get(
project=project_obj,
title=publication_form_data.get('title'),
year=publication_form_data.get('year')
)
publication_obj.delete()

objects.get() implicitly requires 1 result and raises an exception if more match.

Simplest fix

  1. Use the publication's primary key instead of title/year to specify a publication.
  2. In the view showing projects to delete, add a "detail view" (ideally mouseover) that presents additional details about the publication, thus allowing a user to determine the differences between almost-duplicate publications. NOTE: it may be hard for a typical user to distinguish the difference between almost-duplicate publications.

Estimate to fix:
6 hours

Security issue: use of eval() on POST data - publication add via search

Originally mentioned by @dmr-x in context of #4

Problem summary

The Add Publications feature (via search*) makes use of python eval() directly on POST data. Use of eval() is often insecure, and use of it on user-controlled input is definitely insecure.

*NOTE: this is a pre-existing problem, and not a result of the feature in PR #4.

Problem technical

Buggy code snippet:

def post(self, request, *args, **kwargs):
pubs = eval(request.POST.get('pubs'))
project_pk = self.kwargs.get('project_pk')

Simplest fix

  1. Make use of commits* from PR #4 development.
  2. Refactor search-results view to include publication data w/o use of eval(). json.dumps() and json.loads() are probably easiest.

Estimate to fix:
4 hours

*relevant commits:
9c8ae3f

Future suggestion

Use of static analysis tools, such as bandit, could easily identify similar issues during development.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.