Budibase / budibase

Low code platform for building business apps and workflows in minutes. Supports PostgreSQL, MySQL, MariaDB, MSSQL, MongoDB, Rest API, Docker, K8s, and more 🚀
https://budibase.com
Other
22.47k stars 1.55k forks source link

[BUDI-6549] https://cdn.budi.live/app.../attachments/... links from `attachment.url` are not reliable anymore - gives "Missing Key-Pair-Id query parameter" or "Access denied" errors #9663

Closed sergey-vin closed 1 year ago

sergey-vin commented 1 year ago

Hosting

Describe the bug If we upload files via "Attachment" fields, and use URLs of those files in other systems - the URLs will expire over time, and start producing the following errors:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access denied</Message>
</Error>

If we remove "Expires" and "Signature" and "Key-Pair-Id" parts of the URL, the following error shows up:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>MissingKey</Code>
<Message>Missing Key-Pair-Id query parameter or cookie value</Message>
</Error>

To Reproduce Steps to reproduce the behavior:

  1. In "data" - create a BB table "pictures", with 1 "Attachment" field
  2. In "design" - create an auto screen for this table
  3. Also in "design" - add an extra action for the "Save" button - to store attachment.url in some other place (other table, etc.), publish. The URL is like this: https://cdn.budi.live/app.../attachments/......
  4. In "published app" - try uploading files (PDF, PNG, etc.) saving each file as a record in "pictures" table
  5. See the picture links in that other table where you stored them by automation - all files are accessible fine
  6. ... wait for ~1-2 hrs...
  7. See the picture links in that other table where you stored them by automation - none of the files are accessible via URLs anymore, they are "expired".

Additional context

Everything used to work before, and now - not anymore.

Let's try to see who broke it.

An observation: old links stored in the "other table" contained only domain, path and filename and that's it. But new links have some "key-pair", "expiration", "signature" and other parts.

If now I try to open the links saved long time ago, here's what I'd get:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>MissingKey</Code>
<Message>Missing Key-Pair-Id query parameter or cookie value</Message>
</Error>

I assume that there was some change related to enhanced security for uploaded content, and:

  1. it broke compatibility with old links
  2. links became not permanent because the "Expires" part was added

This means that the old schema won't work for us anymore - and we'd either remove this extra security somehow or re-save all assets periodically to update the "Expires" flag.

Expected behavior Regardless of who saves the attachments - they should all have the working URLs, to be later used somewhere else.

If there is a setting which kills that extra security added to the bucket - give a hint please, on how to enable it.

Also, will moving to "self hosted" solution help with that somehow? If we host BB, we'll also host the storage for uploaded content - can we turn the extra security OFF there?


Old bug description (for history)

~Describe the bug~ ~There are several users uploading files via "Attachment" fields. If I upload it - everything works, but if other user do - then the files are visible in admin budibase app, but the links to uploaded files can't be used anywhere else - they show~

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access denied</Message>
</Error>

~To Reproduce~ ~Steps to reproduce the behavior:~ ~1. In "data" - create a BB table "pictures", with 1 "Attachment" field~ ~2. In "design" - create an auto screen for this table~ ~5. Also in "design" - add an extra action for the "Save" button - to store attachment.url in some other place (other table, etc.), publish. The URL is like this: https://cdn.budi.live/app.../attachments/......~ ~6. In "published app" - try uploading files (PDF, PNG, etc.) by different users, saving each file as a record in "pictures" table~ ~7. See the picture links in that other table where you stored them by automation - only some of them will be accessible, other will show the error~ ~8. What's more, if the user for whom the links are saved correctly opens in the "published app" the records which were wrongly saved before - they will be saved correctly this time. So it seems that it depends on the user who creates/updates the images via the app.~

BUDI-6549

BUDI-6563

shogunpurple commented 1 year ago

@sergey-vin what's your tenantId? You haven't included it in the issue.

sergey-vin commented 1 year ago

Hi @shogunpurple . I don't think tenantId is important, since I ran more tests and came up with the fact that it's Expiration that kills everything. I'll update the ticket.

My requests stays the same - is it possible to remove Expiration somehow? We are using images uploaded via Budibase in other places, and now - we can't do it anymore. The URLs expire over time.

sergey-vin commented 1 year ago

hi @shogunpurple , so are you taking this to work? I see that you've modified the ticket title. Thanks.

shogunpurple commented 1 year ago

@sergey-vin no, I was just tidying up the title after an automated tool tagged it twice. We are debugging the issue and finding a way to potentially enable this use case. Will keep you updated

sergey-vin commented 1 year ago

Thanks. If possible, please provide some ETA.

Also, given that this is a new way to represent URLs -

https://cdn.budi.live/app_.../attachments/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png?Expires=1676373723&Policy=xxx&Signature=xxx&Key-Pair-Id=xxx

instead of

https://cdn.budi.live/app_.../attachments/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png

Thanks.

sergey-vin commented 1 year ago

any news, @shogunpurple ?

shogunpurple commented 1 year ago

@sergey-vin as mentioned we will keep you updated as we work through it - it’s a bit of an edge case given the attachments are stored in another table, not being fetched through the API and the security feature is there to prevent totally public, unrestricted access of attachments (which was the case before)

sergey-vin commented 1 year ago

But what if that's what we want - to have public access to those assets? There at least should be an option public vs protected.

fck1tall commented 1 year ago

Any answer here please? I was using budibase too. And i'm quite interested in this case as well!

Any suggestions to solve it from your team? No Any explanation what Budibase suggests in exchange of broken functionality? No Any explanation how exactly Budibase provides ability to use public available CDN for now? No Rollback this feature until you're be able to provide a decent answer? No

Just totally broken for almost a month. Now we're trying to move from budibase to another counterparty because of it. What a shame.

aptkingston commented 1 year ago

Any answer here please? I was using budibase too. And i'm quite interested in this case as well!

Any suggestions to solve it from your team? No Any explanation what Budibase suggests in exchange of broken functionality? No Any explanation how exactly Budibase provides ability to use public available CDN for now? No Rollback this feature until you're be able to provide a decent answer? No

Just totally broken for almost a month. Now we're trying to move from budibase to another counterparty because of it. What a shame.

@fck1tall firstly I'm sorry to hear that this change has caused problems for you. This was a very important change to improve the security of all attachments, as it ensures that only you can access your attachments, rather than having globally public assets simply obscured by UUIDs.

When you retrieve a row from the Budibase API which includes an attachment, it will now automatically include an ephemeral signed link to access attachment fields. Attachments continue to work exactly like they always have, with the exception of links to the actual files themselves are no longer permanent.

Budibase is not intended to be used as an object store for other applications - attachment fields are intended to be fetched using Budibase APIs. If you're uploading attachments inside Budibase DB rows then you need to use the Budibase DB API to access those attachments again, allowing us to properly apply role based access control.

If you want to use Budibase as a public object store for other applications (and are self hosted) then you can probably leverage our S3 connector and connect it to our bundled Minio instance, which I imagine will provide similar functionality to how our previous insecure attachment system worked.

Our main concern is that Budibase apps have secure access to attachments, and that is now the case with this change.

If you want provide more details on how you're storing and using Budibase attachment URLs then it would help us as we decide if additional features are needed for attachments. I appreciate you're frustrated, but you've added no additional context and simply complained at this important security change.

sergey-vin commented 1 year ago

Hi @aptkingston, I share the problems that @fck1tall brought up here. And I'm also searching for alternatives now because of this change you made. If there was a way to roll back the "privacy" change somehow, that would be great, for example:

shogunpurple commented 1 year ago

@sergey-vin @fck1tall just want to clear up a few things here.

@fck1tall maybe you are trying to live up to your github username, but I would imagine you already know that asking for things in that way won't give you the outcome you want. I'm sorry that you are frustrated and you have had problems with the change. Rollback this feature until you're be able to provide a decent answer for example is clearly something that we (or any other company) are not going to do.

The security and role based access control of potentially sensitive documents is more important than allowing budibase to be used as a completely free, fully managed and hosted object store in other apps. Being able to host all attachments publicly in our hosted cloud S3 bucket, with no limits, was always temporary - and we will be bringing in storage and upload limits on our cloud plans for file uploads. However - much better attachment/media features will come along with that. Threatening to switch to alternatives to get something shipped faster is unlikely to impact decision making in open source repositories either. Secured and non-public attachments that must be accessed through authenticated APIs doesn't fit your use case, and that's okay. It does however fit the core use cases of attachments in budibase, or we would not have made the change in the first place.

@sergey-vin has done some (appreciated) research around this issue, and I believe has laid it out quite well. There's 2 core issues here:

To clarify - we will not provide ETAs on large, non-core functionality like this unless it makes sense.

In the meantime, here are some next steps in order of effort (least to most):

Again I apologise for your issues, but I believe there's not much more to be said here, and if the conversation is not productive I think it would be best to lock to collaborators.

Thank you.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity.

jasonford1 commented 1 year ago

I know this comment is closed, but just chiming in that this use case was vital to my app (sales rep uploads quote and then the quote is shared with customer). I'll migrate to S3 as best I can, but the stock budibase attachment module appeared perfect only to have customers reply "access denied" and then find this thread.