Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section DNS Server
  • Search

Everyone can create subdomains!

Questions regarding the DNS Server
BIND
Post Reply
  • Print view
Advanced search
9 posts • Page 1 of 1
mike08
Posts: 160
Joined: Sat Jun 20, 2015 7:12 am

Os: Debian 6x
Web: apache + nginx
Everyone can create subdomains!
  • Quote

Post by mike08 » Sat Aug 29, 2015 4:26 pm

Hello to all,

I'd like to know how can I prevent people creating subdomain names on behalf of other accounts, let me give you an example:
We will put a situation where to users are set:
User A: damaina.tls
User B: domainb.tls

Now, the normal User A can create subdomain names using the domain name domainb.tls like blog.domainb.tls and as well for the User B.

As long as both domains are pointing to the same server both user are going to be able to create subdomain names on behalf others. is there a way to prevent that? Here is my DNS template for all domain names:

Code: Select all

ID='1' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns1%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='2' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns2%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='3' RECORD='@' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='4' RECORD='mail' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='5' RECORD='www' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='6' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='7' RECORD='ftp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='8' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='mail.%domain%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='9' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='10' RECORD='mysql' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
Top

Felix
Posts: 134
Joined: Tue Aug 04, 2015 7:15 pm

Os: Ubuntu 15x
Web: apache + nginx
Re: Everyone can create subdomains!
  • Quote

Post by Felix » Fri Sep 11, 2015 9:33 am

Heya,

According to my tests, the following is possible (exactly the same results as the OP):
User1 has TLD1 hosted on VESTA
User2 has TLD2 hosted on VESTA

User1 can create and operate normaly subdomain.TLD2
User2 can create and operate normaly subdomain.TLD1

This seems to be a VERY SERIOUS issue! And I don't see a way how to resolve this... :-(

If you have only one user on VestaCP, you don't really care about this, but I don't think VestaCP was created to be a single user Control Panel >.<
Top

mike08
Posts: 160
Joined: Sat Jun 20, 2015 7:12 am

Os: Debian 6x
Web: apache + nginx
Re: Everyone can create subdomains!
  • Quote

Post by mike08 » Tue Sep 22, 2015 9:04 pm

Yeah, its really bad because everyone can manage subdomains on behalf others. :(
Top

KuJoe
Posts: 8
Joined: Wed Mar 04, 2015 11:51 am

Re: Everyone can create subdomains!
  • Quote

Post by KuJoe » Sat Sep 26, 2015 7:30 am

This is an issue with some other control panels also so it's not exclusive to VestaCP. Unfortunately the other control panels have known about it for months and haven't fixed it. I'll see if I can throw something together for VestaCP tonight.
Top

KuJoe
Posts: 8
Joined: Wed Mar 04, 2015 11:51 am

Re: Everyone can create subdomains!
  • Quote

Post by KuJoe » Sat Sep 26, 2015 8:25 am

Coded a fix for this but it's not perfect. It will not let users add domains if the TLD has two periods in it (like .co.uk, .us.com, .org.au, etc...).

Edit /usr/local/vesta/web/add/web/index.php:

Find:

Code: Select all

    // Set domain name to lowercase and remove www prefix
    $v_domain = preg_replace("/^www\./i", "", $_POST['v_domain']);
    $v_domain = escapeshellarg($v_domain);
    $v_domain = strtolower($v_domain);
Add below:

Code: Select all

   if(substr_count($v_domain, '.') > 1) {
        $parts = explode('.', $v_domain);
        end($parts);
        $domain = prev($parts).'.'.end($parts);
        $domain = substr($domain, 0, -1);
        if(!is_dir('/home/'.$user.'/web/'.$domain)) {
            $_SESSION['error_msg'] = __('You cannot create a subdomain for a domain not already in your account.',$error_msg);
        }
    }
Like I said, not perfect but a temporary fix.
Top

mike08
Posts: 160
Joined: Sat Jun 20, 2015 7:12 am

Os: Debian 6x
Web: apache + nginx
Re: Everyone can create subdomains!
  • Quote

Post by mike08 » Thu Oct 01, 2015 12:25 pm

Awesome KuJoe,

Ill give it a try, you are the man, thanks.
Top

dvgroup.co.in
Posts: 4
Joined: Mon Jan 25, 2021 8:20 am

Os: CentOS 6x
Web: apache + nginx
Re: Everyone can create subdomains!
  • Quote

Post by dvgroup.co.in » Mon Jan 25, 2021 8:57 am

I have fixed this. With this code, if user A own domain abc.com then user B would not be able to add xyz.abc.com.

You can read all the details in my blog how I fixed it.

https://dv-hosting.com/blog_detail.php?id=6
Top

WQYU
Posts: 6
Joined: Sun Mar 27, 2022 3:46 am

Os: CentOS 4x
Web: apache + nginx
Re: Everyone can create subdomains!
  • Quote

Post by WQYU » Sat Dec 16, 2023 3:22 am

KuJoe wrote: ↑
Sat Sep 26, 2015 8:25 am
Coded a fix for this but it's not perfect. It will not let users add domains if the TLD has two periods in it (like .co.uk, .us.com, .org.au, etc...).

Edit /usr/local/vesta/web/add/web/index.php:

Find:

Code: Select all

    // Set domain name to lowercase and remove www prefix
    $v_domain = preg_replace("/^www\./i", "", $_POST['v_domain']);
    $v_domain = escapeshellarg($v_domain);
    $v_domain = strtolower($v_domain);
Add below:

Code: Select all

   if(substr_count($v_domain, '.') > 1) {
        $parts = explode('.', $v_domain);
        end($parts);
        $domain = prev($parts).'.'.end($parts);
        $domain = substr($domain, 0, -1);
        if(!is_dir('/home/'.$user.'/web/'.$domain)) {
            $_SESSION['error_msg'] = __('You cannot create a subdomain for a domain not already in your account.',$error_msg);
        }
    }
Like I said, not perfect but a temporary fix.
Question: If you make this change and VistaCP (VCP), does an update with the update basically undo this? Would I have to constantly make this change each and every single time that VCP updates?
Top

laguaz
Posts: 8
Joined: Fri Dec 06, 2019 4:51 am

Os: Ubuntu 17x
Web: apache + nginx
Re: Everyone can create subdomains!
  • Quote

Post by laguaz » Mon Mar 11, 2024 4:59 am

WQYU wrote: ↑
Sat Dec 16, 2023 3:22 am
KuJoe wrote: ↑
Sat Sep 26, 2015 8:25 am
Coded a fix for this but it's not perfect. It will not let users add domains if the TLD has two periods in it (like .co.uk, .us.com, .org.au, etc...).

Edit /usr/local/vesta/web/add/web/index.php:

Find:

Code: Select all

    // Set domain name to lowercase and remove www prefix
    $v_domain = preg_replace("/^www\./i", "", $_POST['v_domain']);
    $v_domain = escapeshellarg($v_domain);
    $v_domain = strtolower($v_domain);
Add below:

Code: Select all

   if(substr_count($v_domain, '.') > 1) {
        $parts = explode('.', $v_domain);
        end($parts);
        $domain = prev($parts).'.'.end($parts);
        $domain = substr($domain, 0, -1);
        if(!is_dir('/home/'.$user.'/web/'.$domain)) {
            $_SESSION['error_msg'] = __('You cannot create a subdomain for a domain not already in your account.',$error_msg);
        }
    }
Like I said, not perfect but a temporary fix.
Question: If you make this change and VistaCP (VCP)y2mate, does an update with the update basically undo this? Would I have to constantly make this change each and every single time that VCP updatestubidy?
Hi there, could someone help with this? I'm facing the same issue and am searching for a solution. If anyone has one, please mention me. Thank you very much.
Top


Post Reply
  • Print view

9 posts • Page 1 of 1

Return to “DNS Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password