Giter Club home page Giter Club logo

alquist's People

Contributors

konrajak avatar matulma4 avatar nguyeho7 avatar pritzvac avatar sedivy avatar thepetrmarek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

alquist's Issues

Can't start new thread

Alquist crashes with runtime error when being run locally. This happens as soon as I submit a first message via Alquist client.

Here is the log from command line:

  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
    172.17.0.1 - - [19/Nov/2016 15:04:51] "POST / HTTP/1.1" 200 -
    [2016-11-19 15:05:38,263] ERROR in app: Exception on / [POST]
    Traceback (most recent call last):
    File "/usr/lib/python3.5/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
    File "/usr/lib/python3.5/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/usr/lib/python3.5/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
    File "/usr/lib/python3.5/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/usr/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
    File "/usr/lib/python3.5/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
    File "/usr/lib/python3.5/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functionsrule.endpoint
    File "/alquist/IO/input.py", line 44, in get_input
    response = process_request(bot, state, context, text, session)
    File "/alquist/solver.py", line 37, in process_request
    dialogue_logger.log("Entering State: " + str(current_state), session)
    File "/alquist/dialogue_logger.py", line 17, in log
    log_thread.start()
    File "/usr/lib/python3.5/threading.py", line 844, in start
    _start_new_thread(self._bootstrap, ())
    RuntimeError: can't start new thread
    172.17.0.1 - - [19/Nov/2016 15:05:38] "POST / HTTP/1.1" 500 -

[Security] : Path Traversal in the IO module

A path traversal attack (also known as directory traversal) aims to access files and directories that are stored outside the web root folder. By manipulating variables that reference files with “dot-dot-slash (../)” sequences and its variations or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system including application source code or configuration and critical system files. It should be noted that access to files is limited by system operational access control (such as in the case of locked or in-use files on the Microsoft Windows operating system).

This attack is also known as “dot-dot-slash”, “directory traversal”, “directory climbing” and “backtracking”.

Root Cause Analysis

In the case of Alquist, the path traversal vulnerability can be blamed on incorrect usage of the send_from_directory Flask call. The vulnerability occurs due to the code snippet shown below

alquist/IO/input.py

Lines 79 to 82 in 280d99f

@flask.route('/<bot>/<file>', defaults={'path': ''})
@flask.route('/<bot>/<path:path>/<file>')
def get_bot4(bot, path, file):
return send_from_directory("../client/" + path, file)

Here, since the path and file parameters are attacker controlled, the effective directory and filename passed to the send_from_directory call can be controlled by the attacker leading to a path traversal attack.

Proof of Concept

The bug can be verified using the proof of concept similar to the one shown below.

curl -i --path-as-is -s -k -X $'GET' \
    -H $'Host: 0.0.0.0:5000' -H $'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0' -H $'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H $'Accept-Language: en-US,en;q=0.5' -H $'Accept-Encoding: gzip, deflate' -H $'Connection: close' -H $'Upgrade-Insecure-Requests: 1' \
    $'http://0.0.0.0:5000/asd/../../../../../../../../etc/passwd'

Remediation

This can be easily fixed my restricting the value of file and path parameters by a fixed whitelist of possible values.

CVSS 3 Score

CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H

This bug was found using CodeQL by Github

[Security] : Path Traversal in the IO module

A path traversal attack (also known as directory traversal) aims to access files and directories that are stored outside the web root folder. By manipulating variables that reference files with “dot-dot-slash (../)” sequences and its variations or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system including application source code or configuration and critical system files. It should be noted that access to files is limited by system operational access control (such as in the case of locked or in-use files on the Microsoft Windows operating system).

This attack is also known as “dot-dot-slash”, “directory traversal”, “directory climbing” and “backtracking”.

Root Cause Analysis

In the case of Alquist, the path traversal vulnerability can be blamed on incorrect usage of the send_from_directory Flask call. The vulnerability occurs due to the code snippet shown below

alquist/IO/input.py

Lines 69 to 72 in 280d99f

@flask.route('/client/<file>', defaults={'path': ''})
@flask.route('/client/<path:path>/<file>')
def get_bot2(path, file):
return send_from_directory("../client/" + path, file)

Here, since the path and file parameters are attacker controlled, the effective directory and filename passed to the send_from_directory call can be controlled by the attacker leading to a path traversal attack.

Proof of Concept

The bug can be verified using the proof of concept similar to the one shown below.

curl -i --path-as-is -s -k -X $'GET' \
    -H $'Host: 0.0.0.0:5000' -H $'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0' -H $'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H $'Accept-Language: en-US,en;q=0.5' -H $'Accept-Encoding: gzip, deflate' -H $'Connection: close' -H $'Upgrade-Insecure-Requests: 1' \
    $'http://0.0.0.0:5000/client/../../../../../etc/../../../etc/passwd'

Remediation

This can be easily fixed my restricting the value of file and path parameters by a fixed whitelist of possible values.

This bug was found using CodeQL by Github

Make Alquist RESTful

Changes in API

  • Delete /start method
  • Delete /session method
  • Change / method. It will take parameters node_name (string), input_text (string) and context (dictionary), response is next_node_name (string), response_text (array of string), updated_context (dictionary)

Changes in nodes

  • All nodes must be accesible in all times ( they must be created or we have to create them on fly) by their name
  • Node must take context and input_text from API input
  • Node returns text (array of text maybe... in case of multiple message_text states in row), updated context and name of next state

Changes in architecture

  • Delete sessions and it's memory
  • Delete contexts and it's memory

Changes in input

  • Remove buffer of user input messages

telegram client

A client using telegram API, with a way to link users to telegram IDs.

Structured message support

Implement structured messages ie buttons.
Find a way to make structured messages interactive on the client side and add support to the main app.

Persistent context

It would be great to have a way to save context for users using a persistent database or something similar. It would greatly help for personal assistant-type bots.

Direct string saving

It would be nice to be able to save some strings directly, for example during a login we want the username.

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.