Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wgdashboard issue with sqlite table names, does not handle interface names with dash in name #207

Open
epiecs opened this issue Dec 17, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@epiecs
Copy link

epiecs commented Dec 17, 2022

Describe The Problem
Wireguard allows interfaces names that match the following regex: ^[a-zA-Z0-9_=+.-]{1,15}$

In dashboard.py the on line 490 the create_table function crashes when using an interface name such as wg-test.

The reason for this is that SQlite does not allow dashes in database names unless they are quoted. As reference see this {stackoverflow answer](https://stackoverflow.com/a/3694291).

The fix is to replace CREATE TABLE IF NOT EXISTS {i} ( with CREATE TABLE IF NOT EXISTS \"{i}\" (

This will fix the login error. However there are some more locations in the code that still need escaping. For example opening an interface wont work.

Expected Error / Traceback

Dec 17 23:01:02 wireguard python3[40351]:   File "/srv/wgdashboard/src/dashboard.py", line 501, in get_conf_list
Dec 17 23:01:02 wireguard python3[40351]:     g.cur.execute(create_table)
Dec 17 23:01:02 wireguard python3[40351]: sqlite3.OperationalError: near "-": syntax error

To Reproduce
Run the dashboard with an interface with dashes in the name such as wg-test

OS Information:

       _,met$$$$$gg.          root@wireguard
    ,g$$$$$$$$$$$$$$$P.       --------------
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux 11 (bullseye) x86_64
 ,$$P'              `$$$.     Host: KVM/QEMU (Standard PC (i440FX + PIIX, 1996) pc-i440fx-7.1)
',$$P       ,ggs.     `$$b:   Kernel: 5.10.0-19-cloud-amd64
`d$$'     ,$P"'   .    $$$    Uptime: 1 day, 2 hours, 8 mins
 $$P      d$'     ,    $$P    Packages: 451 (dpkg)
 $$:      $$.   -    ,d$$'    Shell: bash 5.1.4
 $$;      Y$b._   _,d$P'      CPU: Intel i7-8559U (2) @ 2.711GHz
 Y$$.    `.`"Y$$$$P"'         Memory: 112MiB / 1985MiB
 `$$b      "-.__
  `Y$$
   `Y$$.
     `$$b.
       `Y$$b.
          `"Y$b._
              `"""

python3 -V
Python 3.9.2

Sample of your .conf file

default file without any changes
@epiecs epiecs added the bug Something isn't working label Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant