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

🐛 Improve admin security over dnshole controls #1686

Merged
merged 3 commits into from
Jan 11, 2024

Conversation

SeDemal
Copy link
Collaborator

@SeDemal SeDemal commented Nov 21, 2023

Category

Bugfix / Security

Overview

  1. Although DNS toggle all controls where hidden, the per item badge was still active.
  2. Toggle function was not safe from CSS manipulation to regain access to it, made the toggle function only answer to admin users.
  3. Non admins didn't have controls elements centered.

Change allow controls to server side.
Added ability to enable controls for non admins (But still users at least) with widget option.

Issue Number

Reported in #1685

Copy link
Owner

@ajnart ajnart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how to protect the api call from being made by non admins. This call should be restricted to logged-in users and not only admins.
please read about “admin procedures” and try to understand how trpc works with that. Also you could’ve just put the conditions inside of the react query use mutation call

@SeDemal SeDemal force-pushed the dns-hole-improve-admin-controls branch from bf9044f to 91d657b Compare November 21, 2023 12:47
Copy link
Owner

@ajnart ajnart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for settings like these, it still will allow requests if the user just modifies the HTML, please read my comment and try to understand the trpc server

@SeDemal
Copy link
Collaborator Author

SeDemal commented Nov 21, 2023

There is no need for settings like these, it still will allow requests if the user just modifies the HTML, please read my comment and try to understand the trpc server

Changed to protected procedure, but as mentioned in #1685 and as how the widget was initially changed, controlling network behaviour's is an admin procedure. The solution I'm adding is an extra to let normal users use it although they shouldn't be able to.
Since the router uses the config, there is no way to manipulate the html to somehow change the config and unlock the function. That's the whole point, if you manipulate the html, all you'll get is the TRPCError Unauthorized.

@SeDemal SeDemal requested a review from ajnart November 23, 2023 16:29
@ajnart
Copy link
Owner

ajnart commented Nov 26, 2023

There is no need for settings like these, it still will allow requests if the user just modifies the HTML, please read my comment and try to understand the trpc server

Changed to protected procedure, but as mentioned in #1685 and as how the widget was initially changed, controlling network behaviour's is an admin procedure. The solution I'm adding is an extra to let normal users use it although they shouldn't be able to. Since the router uses the config, there is no way to manipulate the html to somehow change the config and unlock the function. That's the whole point, if you manipulate the html, all you'll get is the TRPCError Unauthorized.

The thing is just that admin procedure = admin can do it and protected = logged-in users, there is no point to do a protected procedure and then check if the user is an admin, just use an admin procedure. The normal users can still click the buttons but it will return an error when doing so

@SeDemal
Copy link
Collaborator Author

SeDemal commented Nov 26, 2023

There is no need for settings like these, it still will allow requests if the user just modifies the HTML, please read my comment and try to understand the trpc server

Changed to protected procedure, but as mentioned in #1685 and as how the widget was initially changed, controlling network behaviour's is an admin procedure. The solution I'm adding is an extra to let normal users use it although they shouldn't be able to. Since the router uses the config, there is no way to manipulate the html to somehow change the config and unlock the function. That's the whole point, if you manipulate the html, all you'll get is the TRPCError Unauthorized.

The thing is just that admin procedure = admin can do it and protected = logged-in users, there is no point to do a protected procedure and then check if the user is an admin, just use an admin procedure. The normal users can still click the buttons but it will return an error when doing so

Ok I might have not expressed it properly, I did at first only want admins to be able to use it to follow what was already done before, just improperly. I didn't know in my first draft about protected and admin procedure.
In the following modification, I did learn about those, both actually, but choose protected procedure because of the first comment you left.
I've only added the ability to let normal users interact with it because you mentioned it could be a protected procedure and not limited to admins.
I somewhat agree to that but the option is there to let sys admins choose whether or not they want to let their user access that function.
Now if we're all ok with protecting it only behind admin procedure and no normal user interaction, I'm all fine with it. I can remove the extra things and make it 100% admin.

@ajnart
Copy link
Owner

ajnart commented Nov 26, 2023

Oooh okay makes sense. Then we make it admin only

@ajnart
Copy link
Owner

ajnart commented Nov 26, 2023

This will be better whenever we have a more fine grained permission system

@SeDemal
Copy link
Collaborator Author

SeDemal commented Nov 26, 2023

Ok, will do that, thanks :)

@SeDemal SeDemal force-pushed the dns-hole-improve-admin-controls branch 3 times, most recently from ba1924e to 4414c0d Compare November 26, 2023 22:43
@SeDemal SeDemal force-pushed the dns-hole-improve-admin-controls branch from 4414c0d to 21d5c84 Compare November 26, 2023 22:53
Copy link
Collaborator

@Meierschlumpf Meierschlumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@manuel-rw manuel-rw merged commit 60bca74 into ajnart:dev Jan 11, 2024
1 check passed
@manuel-rw manuel-rw deleted the dns-hole-improve-admin-controls branch January 11, 2024 18:04
truecharts-admin added a commit to truecharts/charts that referenced this pull request Jan 19, 2024
…ee7babc by renovate (#17301)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/ajnart/homarr](https://togithub.com/ajnart/homarr) | patch |
`0.14.3` -> `0.14.4` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>ajnart/homarr (ghcr.io/ajnart/homarr)</summary>

### [`v0.14.4`](https://togithub.com/ajnart/homarr/releases/tag/v0.14.4)

[Compare
Source](https://togithub.com/ajnart/homarr/compare/v0.14.3...v0.14.4)

#### Deeper integration in Home Assistant

Want to toggle your lights? Have a fun to switch on? Or maybe you want
to send a reminder to your family?
We've upgraded the existing entity state widget and added a new widget
that support invoking automations on your Homeassistant.
Homeassistant's vast library of integrations enable you to make complex
workflow that can be easily started with a single click from Homarr:

![294787853-80066fc3-545a-4486-80f6-eafff6c6fab3](https://togithub.com/ajnart/homarr/assets/30572287/e0b9b572-3b3c-4261-9fb2-f2dc8813fc2b)

#### Improved layout & performance for torrent widget

We've improved the layout for smaller screens and significantly cut down
the bandwidth required for the torrent widget.
This should result in less lag and faster updating on your widget.


![294015178-a7c82d43-6b6f-4eee-a578-32e0baf7f738](https://togithub.com/ajnart/homarr/assets/30572287/fc4814ac-eca3-45f1-9e58-fc3581d34a32)

#### Renaming & duplicating boards

We've heard you: boards can now be renamed / or duplicated. You don't
need to mess with any files on the filesystem.

#### JSON API

We know that there are many advanced users who want to take better
control of Homarr's capabilities.
Therefore, we've added a JSON API that can be used to execute almost any
action that you can from the WEB UI.
We provide an Open API specification document that enables you to easily
browse your API endpoints:

![296549433-8cc29984-7bfb-4238-869b-e02a48ae95e9](https://togithub.com/ajnart/homarr/assets/30572287/f3229f31-2f31-4124-86d3-f2038fa87ad0)

#### Fixed local paths in icon picker

Previously, the local icons were hard to use and had the wrong path by
default.
We have fixed this problem and added the size of the file as an
additional information.

#### Availability of media requests

[@&#8203;tancak](https://togithub.com/tancak) has contributed the
displaying of availability information on requests:

![294605516-1bd64ba4-4ba4-45f5-8539-7c69bb964694](https://togithub.com/ajnart/homarr/assets/30572287/9e2bad2d-169e-4d6d-93da-81e0b52f86a6)

##### What's Changed

- docs: updated dead installation links in README.md by
[@&#8203;stark1tty](https://togithub.com/stark1tty) in
[ajnart/homarr#1775
- refactor: improve torrent table design by
[@&#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1786
- docs: fix documentation link URL after creating user by
[@&#8203;StefanB7](https://togithub.com/StefanB7) in
[ajnart/homarr#1796
- feat: add availability information about media requests by
[@&#8203;tancak](https://togithub.com/tancak) in
[ajnart/homarr#1794
- feature: trigger automations by
[@&#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1799
- feature:
[#&#8203;1765](https://togithub.com/ajnart/homarr/issues/1765) reduce
transferred torrent data by
[@&#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1798
- fix: database is not initialized inside the docker container by
[@&#8203;anonysoul](https://togithub.com/anonysoul) in
[ajnart/homarr#1806
- chore: increase version by
[@&#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1811
- feature: improve admin security over dnshole controls by
[@&#8203;Tagaishi](https://togithub.com/Tagaishi) in
[ajnart/homarr#1686
- feature: rss improvements by
[@&#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1810
- feature: board operations by
[@&#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1800
- revert: [#&#8203;1714](https://togithub.com/ajnart/homarr/issues/1714)
migrate to axios.get by
[@&#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1819
- chore: new Crowdin updates by
[@&#8203;ajnart](https://togithub.com/ajnart) in
[ajnart/homarr#1772
- feature: add trpc openapi by
[@&#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1818
- refactor: optimize imports by
[@&#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1822
- chore: New Crowdin updates by
[@&#8203;ajnart](https://togithub.com/ajnart) in
[ajnart/homarr#1820
- fix: [#&#8203;1734](https://togithub.com/ajnart/homarr/issues/1734)
fix local icons path by
[@&#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1821

#### New Contributors

- [@&#8203;stark1tty](https://togithub.com/stark1tty) made their first
contribution in
[ajnart/homarr#1775
- [@&#8203;StefanB7](https://togithub.com/StefanB7) made their first
contribution in
[ajnart/homarr#1796
- [@&#8203;tancak](https://togithub.com/tancak) made their first
contribution in
[ajnart/homarr#1794
- [@&#8203;anonysoul](https://togithub.com/anonysoul) made their first
contribution in
[ajnart/homarr#1806

**Full Changelog**:
ajnart/homarr@v0.14.3...v0.14.4

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10pm on monday" in timezone
Europe/Amsterdam, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNDAuOSIsInVwZGF0ZWRJblZlciI6IjM3LjE0MC45IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=-->
GabrielBarzen pushed a commit to GabrielBarzen/charts that referenced this pull request Feb 2, 2024
…ee7babc by renovate (truecharts#17301)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/ajnart/homarr](https://togithub.com/ajnart/homarr) | patch |
`0.14.3` -> `0.14.4` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>ajnart/homarr (ghcr.io/ajnart/homarr)</summary>

### [`v0.14.4`](https://togithub.com/ajnart/homarr/releases/tag/v0.14.4)

[Compare
Source](https://togithub.com/ajnart/homarr/compare/v0.14.3...v0.14.4)

#### Deeper integration in Home Assistant

Want to toggle your lights? Have a fun to switch on? Or maybe you want
to send a reminder to your family?
We've upgraded the existing entity state widget and added a new widget
that support invoking automations on your Homeassistant.
Homeassistant's vast library of integrations enable you to make complex
workflow that can be easily started with a single click from Homarr:

![294787853-80066fc3-545a-4486-80f6-eafff6c6fab3](https://togithub.com/ajnart/homarr/assets/30572287/e0b9b572-3b3c-4261-9fb2-f2dc8813fc2b)

#### Improved layout & performance for torrent widget

We've improved the layout for smaller screens and significantly cut down
the bandwidth required for the torrent widget.
This should result in less lag and faster updating on your widget.


![294015178-a7c82d43-6b6f-4eee-a578-32e0baf7f738](https://togithub.com/ajnart/homarr/assets/30572287/fc4814ac-eca3-45f1-9e58-fc3581d34a32)

#### Renaming & duplicating boards

We've heard you: boards can now be renamed / or duplicated. You don't
need to mess with any files on the filesystem.

#### JSON API

We know that there are many advanced users who want to take better
control of Homarr's capabilities.
Therefore, we've added a JSON API that can be used to execute almost any
action that you can from the WEB UI.
We provide an Open API specification document that enables you to easily
browse your API endpoints:

![296549433-8cc29984-7bfb-4238-869b-e02a48ae95e9](https://togithub.com/ajnart/homarr/assets/30572287/f3229f31-2f31-4124-86d3-f2038fa87ad0)

#### Fixed local paths in icon picker

Previously, the local icons were hard to use and had the wrong path by
default.
We have fixed this problem and added the size of the file as an
additional information.

#### Availability of media requests

[@&truecharts#8203;tancak](https://togithub.com/tancak) has contributed the
displaying of availability information on requests:

![294605516-1bd64ba4-4ba4-45f5-8539-7c69bb964694](https://togithub.com/ajnart/homarr/assets/30572287/9e2bad2d-169e-4d6d-93da-81e0b52f86a6)

##### What's Changed

- docs: updated dead installation links in README.md by
[@&truecharts#8203;stark1tty](https://togithub.com/stark1tty) in
[ajnart/homarr#1775
- refactor: improve torrent table design by
[@&truecharts#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1786
- docs: fix documentation link URL after creating user by
[@&truecharts#8203;StefanB7](https://togithub.com/StefanB7) in
[ajnart/homarr#1796
- feat: add availability information about media requests by
[@&truecharts#8203;tancak](https://togithub.com/tancak) in
[ajnart/homarr#1794
- feature: trigger automations by
[@&truecharts#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1799
- feature:
[#&truecharts#8203;1765](https://togithub.com/ajnart/homarr/issues/1765) reduce
transferred torrent data by
[@&truecharts#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1798
- fix: database is not initialized inside the docker container by
[@&truecharts#8203;anonysoul](https://togithub.com/anonysoul) in
[ajnart/homarr#1806
- chore: increase version by
[@&truecharts#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1811
- feature: improve admin security over dnshole controls by
[@&truecharts#8203;Tagaishi](https://togithub.com/Tagaishi) in
[ajnart/homarr#1686
- feature: rss improvements by
[@&truecharts#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1810
- feature: board operations by
[@&truecharts#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1800
- revert: [#&truecharts#8203;1714](https://togithub.com/ajnart/homarr/issues/1714)
migrate to axios.get by
[@&truecharts#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1819
- chore: new Crowdin updates by
[@&truecharts#8203;ajnart](https://togithub.com/ajnart) in
[ajnart/homarr#1772
- feature: add trpc openapi by
[@&truecharts#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1818
- refactor: optimize imports by
[@&truecharts#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1822
- chore: New Crowdin updates by
[@&truecharts#8203;ajnart](https://togithub.com/ajnart) in
[ajnart/homarr#1820
- fix: [#&truecharts#8203;1734](https://togithub.com/ajnart/homarr/issues/1734)
fix local icons path by
[@&truecharts#8203;manuel-rw](https://togithub.com/manuel-rw) in
[ajnart/homarr#1821

#### New Contributors

- [@&truecharts#8203;stark1tty](https://togithub.com/stark1tty) made their first
contribution in
[ajnart/homarr#1775
- [@&truecharts#8203;StefanB7](https://togithub.com/StefanB7) made their first
contribution in
[ajnart/homarr#1796
- [@&truecharts#8203;tancak](https://togithub.com/tancak) made their first
contribution in
[ajnart/homarr#1794
- [@&truecharts#8203;anonysoul](https://togithub.com/anonysoul) made their first
contribution in
[ajnart/homarr#1806

**Full Changelog**:
ajnart/homarr@v0.14.3...v0.14.4

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10pm on monday" in timezone
Europe/Amsterdam, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNDAuOSIsInVwZGF0ZWRJblZlciI6IjM3LjE0MC45IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants