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

Tagged devices should not have access permissions of their owning user #1369

Open
vbrandl opened this issue Apr 20, 2023 · 14 comments
Open

Tagged devices should not have access permissions of their owning user #1369

vbrandl opened this issue Apr 20, 2023 · 14 comments
Labels
bug Something isn't working no-stale-bot policy 📝
Milestone

Comments

@vbrandl
Copy link

vbrandl commented Apr 20, 2023

Bug description

I want to allow my personal devices to ssh into my servers but not allow my servers to ssh between each other. All devices belong to the same headscale user. My servers are tagged ssh, my personal devices are untagged and my user is in the sshuser group.

The Tailscale documentation states (https://tailscale.com/kb/1068/acl-tags/#authentication-and-authorization):

Once a device has been tagged, it loses the access permissions of the human user who tagged it, and acquires any access permissions granted to its tags. In other words, if you log into a device as dave@tailscale.com and then tag it with tag:server, the device no longer has any of the network permissions granted to dave@tailscale.com, and instead is subject to the access rules for tag:server. If the user who added the device is deleted, the device will remain.

According to the Tailscale documentation, I would expect a ACL allowing ssh from group:sshuser to tag:ssh to produce the described behaviour. All my untagged devices should be able to ssh into the tagged servers (which they do) but my servers are also able to ssh between each other.

To Reproduce

{
    "groups":{
        "group:sshuser":[
            "me"
        ]
    },
    "tagOwners": {
        "tag:ssh": ["me"]
    },
    "ssh": [
        {
            "action": "accept",
            "src": ["group:sshuser"],
            "dst": ["tag:ssh"],
            "users": ["allowlisted-user"]
        }
    ]
}

Context info

  • Headscale: v0.22.1
@vbrandl vbrandl added the bug Something isn't working label Apr 20, 2023
@github-actions
Copy link
Contributor

This issue is stale because it has been open for 180 days with no activity.

@github-actions github-actions bot added the stale label Oct 18, 2023
@vbrandl
Copy link
Author

vbrandl commented Oct 29, 2023

This seems like a security bug to me, since it does not match the behavior of tailscale. Can anyone with more in-depth knowledge comment on this?

@github-actions github-actions bot removed the stale label Oct 30, 2023
Copy link
Contributor

This issue is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale label Jan 28, 2024
@kradalby kradalby removed the stale label Jan 30, 2024
@kradalby
Copy link
Collaborator

Yes, you are right, they should be "detached" from the user when they are tagged. Right now we dont have the code necessary to handle this. I have removed the stale tag for further tracking.

Per now I would classify it as "ACLs are not fully implemented" rather than a security bug as we do not support all features.

@vbrandl
Copy link
Author

vbrandl commented Jan 30, 2024

Since there are various places in the headscale documentation, that link to https://tailscale.com/kb/1068/acl-tags, where the "detaching" behavior is described, I would still consider this a security bug. As a user reading the documentation, it is not clear, where and how headscale diverges from tailscale. This seems dangerous to me...

Copy link
Contributor

This issue is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale label May 16, 2024
@vbrandl
Copy link
Author

vbrandl commented May 16, 2024

I don't think this should be marked as stale and forgotten...

@kradalby kradalby removed the stale label May 16, 2024
@kradalby
Copy link
Collaborator

I agree, removed the mark, we just have not had capacity to get to it.

@kradalby
Copy link
Collaborator

I made a PR doing some of the untangeling work to make this possible, removing the username from magicdns names. Which should make this a tiny bit easier.

@mikelococo
Copy link

mikelococo commented Jul 23, 2024

... removing the username from magicdns names.

Are there any suggested strategies for maintaining hostname continuity in the face of this change? This seems like a more-significant-than-usual breaking change in that it's likely to require changes not just to the headscale config but to potentially all services and clients on the tailnet that know each other by their MagicDNS name.

I see in https://github.com/juanfont/headscale/releases/tag/v0.23.0-beta1 that it suggests a temporary workaround, but one that is planned to be removed:

use_username_in_magic_dns can be used to turn this behaviour on again, but note that this option will be removed when tags are fixed.

Does extra_records provide a path to maintain the existing MagicDNS entries? https://github.com/juanfont/headscale/blob/main/docs/dns-records.md discusses the config-format but is silent on the relationship between extra_records, base_domain, and auto-assigned MagicDNS entries. Is using extra_records to emulate the old username-style subdomains valid?

If one only cares about dns name continuity for the nodes registered to a single user, is modifying the base_domain of an existing tailscale instance a valid migration strategy? For example, chaging the base_domain from example.com to myuser.example.com such that all nodes now appear at the FQDN previously reserved for nodes registered to myuser.

I feel like this change in particular is likely to generate migration/support questions due to the very disruptive nature of changing existing names, some amount of migration guidance would be quite helpful as the release nears.

@nblock
Copy link
Collaborator

nblock commented Sep 10, 2024

Does extra_records provide a path to maintain the existing MagicDNS entries? https://github.com/juanfont/headscale/blob/main/docs/dns-records.md discusses the config-format but is silent on the relationship between extra_records, base_domain, and auto-assigned MagicDNS entries. Is using extra_records to emulate the old username-style subdomains valid?

I tested the extra_records approach you mentioned and it works:

Setup

  • laptop assigned to user alice: 100.64.0.2, fd7a:115c:a1e0::2
  • server assigned to user bob: 100.64.0.3, fd7a:115c:a1e0::3
  • Tailscale 1.72.1 on Debian 12, MagicDNS enabled
  • Headscale 0.23.0-beta.4

Results

Testcase: use_username_in_magic_dns=true

Headscale configuration:

dns:
  use_username_in_magic_dns: true
  base_domain: tn.example.com
  extra_records:
    - {name: "extra.example.com", type: "A", value: "198.51.100.1"}
    - {name: "extra.example.com", type: "AAAA", value: "2001:db8::1"}

Content of: /etc/resolv.conf on server:

nameserver 100.100.100.100
search tn.example.com bob.tn.example.com

Lookup results (via: dig +short @100.100.100.100 NAME A/AAAA)

Name IPv4 IPv6
server.tn.example.com - -
server.bob.tn.example.com 100.64.0.3 -
laptop.tn.example.com - -
laptop.alice.tn.example.com 100.64.0.2 -
extra.example.com 198.51.100.1 2001:db8::1

Testcase: use_username_in_magic_dns=false and extra records for nodes

Headscale configuration:

dns:
  use_username_in_magic_dns: false
  base_domain: tn.example.com
  extra_records:
    - {name: "extra.example.com", type: "A", value: "198.51.100.1"}
    - {name: "extra.example.com", type: "AAAA", value: "2001:db8::1"}
    - {name: "laptop.alice.tn.example.com", type: "A", value: "100.64.0.2"}
    - {name: "laptop.alice.tn.example.com", type: "AAAA", value: "fd7a:115c:a1e0::2"}
    - {name: "server.bob.tn.example.com", type: "A", value: "100.64.0.3"}
    - {name: "server.bob.tn.example.com", type: "AAAA", value: "fd7a:115c:a1e0::3"}

Content of: /etc/resolv.conf on server:

nameserver 100.100.100.100
search tn.example.com

Lookup results (via: dig +short @100.100.100.100 NAME A/AAAA)

Name IPv4 IPv6
server.tn.example.com 100.64.0.3 -
server.bob.tn.example.com 100.64.0.3 fd7a:115c:a1e0::3
laptop.tn.example.com 100.64.0.2 -
laptop.alice.tn.example.com 100.64.0.2 fd7a:115c:a1e0::2
extra.example.com 198.51.100.1 2001:db8::1

@kradalby do you consider the above approach as recommended, long-term "workaround" once dns.use_username_in_magic_dns is completely removed? If so, I'm going to follow-up with a PR for the DNS docs where this approach is documented for users.

@kradalby
Copy link
Collaborator

@kradalby do you consider the above approach as recommended, long-term "workaround" once dns.use_username_in_magic_dns is completely removed? If so, I'm going to follow-up with a PR for the DNS docs where this approach is documented for users.

I suppose it is a fair workaround, I would recommend not relying on the username based dns names as it will be hard to keep up to date for individuals, but if they are up for it, I suppose it doesnt hurt to call out that this is possible.

@kradalby kradalby modified the milestones: v0.23.0, Next Sep 11, 2024
@almereyda

This comment was marked as outdated.

@nblock
Copy link
Collaborator

nblock commented Sep 12, 2024

server.bob is probably fd7a:115c:a1e0::3 instead.

Fixed, thx!

kradalby added a commit to kradalby/headscale that referenced this issue Sep 27, 2024
this commit denormalises the Tags related to a Pre auth key
back onto the preauthkey table and struct as a string list.

There was not really any real normalisation here as we just added
a bunch of duplicate tags with new IDs and preauthkeyIDs, lots of
GORM cermony but no actual advantage.

This work is the start to fixup tags which currently are not working
as they should.

Updates juanfont#1369

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
kradalby added a commit to kradalby/headscale that referenced this issue Sep 27, 2024
this commit denormalises the Tags related to a Pre auth key
back onto the preauthkey table and struct as a string list.

There was not really any real normalisation here as we just added
a bunch of duplicate tags with new IDs and preauthkeyIDs, lots of
GORM cermony but no actual advantage.

This work is the start to fixup tags which currently are not working
as they should.

Updates juanfont#1369

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
kradalby added a commit that referenced this issue Sep 29, 2024
this commit denormalises the Tags related to a Pre auth key
back onto the preauthkey table and struct as a string list.

There was not really any real normalisation here as we just added
a bunch of duplicate tags with new IDs and preauthkeyIDs, lots of
GORM cermony but no actual advantage.

This work is the start to fixup tags which currently are not working
as they should.

Updates #1369

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-stale-bot policy 📝
Projects
None yet
Development

No branches or pull requests

6 participants
@kradalby @nblock @mikelococo @almereyda @vbrandl and others