Public Call For Security Researchers -- Swarm Multi User System #679
Replies: 4 comments 12 replies
-
Hello! Have you found a person to help with this one? If not or if you would not mind another set of eyes on this one, I would love to try it out. I come from Linux/Java application security background and my analysis will likely be incomplete, but I might be able to spot something of interest. |
Beta Was this translation helpful? Give feedback.
-
Wish it support OIDC in a way that we can simply connect an IdP like authentik or keycloak to manage access rights and groups, etc. SwarmUI will simply take the user profile and roles/groups from the |
Beta Was this translation helpful? Give feedback.
-
Finally had a chance to start looking at the code, there might be an issue with your password storage (P2 area as you call it), depending on what kind of risks you're willing to accept. https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Utils/Utilities.cs#L1255 You're using PBKDF2 which isn't broken but doesn't offer some advantages that more modern schemes will, like memory or asic hardness. But that's not the only thing I see:
I'd personally recommend at least bcrypt for the hashing algorithm these days but my personal preference is Argon2id for the memory and gpu hardness it can help provide, since we're obviously dealing with users that are going to have access to more powerful GPUs (either themselves or by putting in a malicious extension into comfyui to try to break user's hashes in-situ, as this might not be a direct security issue for SwarmUI, it would mean that password re-use in Swarm could lead to a bad actor breaking into other services that a user has. |
Beta Was this translation helpful? Give feedback.
-
I did find some more questions, after digging through the session handling code that may just be me missing where things are happening since it's just a first pass:
https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Accounts/SessionHandler.cs#L349 Might not be a huge deal but it could be leading to a race condition with expiring sessions during clean up, or a sessions being valid even after being expired because clean-up failed. Likely fixable by just adding a method on the session class that does a quick check for expiration and that the user it holds is still valid in the rest of the system and calling that before returning true. I believe that this also means that CleanOldSessions() should also be cleaning up and checking the Sessions ConcurrentDictionary and cleaning that up too? I suspect right now though with things hard coded to 31 day sessions and frequency of updates it's not a huge issue anyway as people won't be leaving the software running incredibly long but it could mean that a sessions seems to stay up until the next restart if this is missed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
If you found this link from elsewhere, you can learn about Swarm in the readme here
Swarm recently added early experimental 'friends and family' multi-user system. That is: a system where you can homehost your SwarmUI, and your friends/family can connect and log in to their own separate accounts and share the UI, separately.
The long term goal of this system is to expand to a 'general open' multi-user system, one you could confidently host on the open internet and grant randos account access to.
I'm relatively experienced in cybersecurity, and have a general idea what I'm doing, but as anyone in cybersec would confirm: the first lesson of knowing cybersec is you don't know enough about cybersec to verify a non-trivially-sized system is 'safe'. And the second rule is nothing is truly 'safe', just sometimes the zero-days haven't been found yet.
So, in the interest of at least minimizing the risk of people getting hurt by trying to host Swarm as much as possible, I'm putting out a public call for those with cybersecurity & software dev experience to look over SwarmUI's multi-account system and hosting, to
(A) identify and fix issues before we suggest anything is ready to host for real, and
(B) try to determine robust recommendations for how less-technically-experienced users can share their personal Swarm instance without getting pwned (eg containerization).
If you have relevant experience, please do poke around and comment below.
Swarm does not currently recommend anyone set this up to the actual public, so network security issues do not (currently) need to be kept private. After there are any recommended public setups, I'll replace this notice with direction towards private security issue reporting.
Bear in mind, Swarm is 100% free and open source software. If you'd like a reward for helping with security validation, I'm happy to give you public thanks or link your page or anything, but there's no money involved. I understand that no money isn't awesome, but I don't get paid for this either. Thus the public call for help instead of hiring someone.
All the notes below are a preliminary writeup, there's probably things I'm missing. Please do suggest any you think of.
Testing/Config Notes
The only upfront config that matters is:
AuthorizationRequired
enabled (obviously)User
or lower role access. (Obviously admins can wreak havoc, powerusers can too. I know.)Validation Priority One: Basic Network Connection
The most important initial baseline is: let's say you host a SwarmUI instance publicly, with account systems enabled, and a random external attacker connects with no account knowledge / no login. What can they do?
P1 Areas of Main Concern
AllowLocalhostBypass
: can a user trick Swarm into thinking they're localhost, when they're not? Notably including when using a reasonably-configured nginx/apache reverse proxy setup (which might resemble localhost, Swarm should be able to identify this is not the case from X-Forwarded-For).P1 Known Issues
P1 Non-Concerns
Validation Priority Two: Account Engine
Naturally, the second factor to consider is the account system itself. When logging in / messing with user accounts, what risks are there?
P2 Areas of Main Concern
P2 Known Issues
P2 Non-Concerns
Validation Priority Three: User-Accessibles
Next up: all that stuff a default user account can access. Is it safe?
P3 Areas of Main Concern
embedding:xyz
that does insufficiently secure file access, does Swarm properly forbid writing that without going through whitelisted checks (<embedding:
swarm syntax)? Are there other syntaxes or sus file inputs?)P3 Known Issues
P3 Non-Concerns
Priority Four: Config Recommendations
How does a user set up a sufficiently secure system?
I have a setup guide for Swarm in Docker, is that docker setup sufficiently secure? (Answer: probably not, due to eg the network config in particular.)
we need a dedicated "Set up a secure public instance" guide that configures things like docker networking to more security-maxed setups, so that less-experienced users can host an instance safely.
("Just don't run it if you're not an expert" is a classic response but not helpful here)
Beta Was this translation helpful? Give feedback.
All reactions