Giter Club home page Giter Club logo

media-proxy's People

Contributors

ragujp avatar tamaina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

media-proxy's Issues

SyntaxError: Unexpected strict mode reserved word

1.NODE_ENV=production pnpm install
2.Manually run npm start
3.

npm WARN config init.module Use `--init-module` instead.

> [email protected] start
> fastify start ./built/index.js

SyntaxError: Unexpected strict mode reserved word
    at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14)

OS:Ubuntu 20.04

Security issue: can proxy any image from any server

The proxy will accept a target URL from query or the params part in the request, then it will download it even if the image if not coming from a Misskey instance in the federation.
That will cause a security issue that as a public proxy server, someone can easily abuse it to proxy something from any server, which might a harmful content, and the abusive behavior can also cause server traffic to be wasted, which can be used to launch malicious attacks on server instances with limited traffic.

Here is a possible solution to this issue:
The misskey instance knows which original servers the inbox receives media files from, and it must have an available URL to pull the original media files. Misskey instance can resolve the domain from the URL of media files, and add them to a whitelist automatically (the whitelist can be saved into DB, and use Redis or something other to notify the proxy that the whitelist should be reloaded), then the proxy can be secured by filter the URL with the domains in the whitelist.

Alternatively, it is also possible to check the domains of the individual instances within the federation, but this may not be as accurate (some instances may use different CDN domains).

(Actually, just add a simple signature can also make things better in a small cost way :D)

CORSヘッダーを付与

CORSヘッダーが無いとMisskey Web側で画像のクロップしようとしたときなどにエラーが出る

メモリリークしてる?

Lambdaのメモリログを見ていると、リクエスト実行ごとに最大メモリ使用が増えている

Node.jsやFastifyの仕様なのか、このコードがダメなのかはわからない

403の判定が正しくない

README.mdを見ると、以下のように記載されています。

/proxyは画像ではないと403を返しますが、Media Proxyではそのまま内容を送信します。
https://github.com/misskey-dev/media-proxy/blob/master/src/index.ts#L206

しかし、ソースを見てみると、そうなっていないように見えます。

// 画像ではないもの、または、ブラウザセーフでないものの場合NGのような条件に見えます
} else if (!file.mime.startsWith('image/') || !FILE_TYPE_BROWSERSAFE.includes(file.mime)) {
            throw new StatusError('Rejected type', 403, 'Rejected type');
// ----------------------------------------------------------------------------------------
// ブラウザセーフでないものの場合、403返す(こちらの動きが正しい?)
} else if (!FILE_TYPE_BROWSERSAFE.includes(file.mime)) {
            throw new StatusError('Rejected type', 403, 'Rejected type');

意図通りではないなら修正したほうがいいと思います。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.