Code Monkey home page Code Monkey logo

discord-embed's People

Contributors

dependabot[bot] avatar pre-commit-ci[bot] avatar renovate-bot avatar renovate[bot] avatar thelovinator1 avatar

Stargazers

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

Watchers

 avatar  avatar

discord-embed's Issues

Problem with redirection

Hi,

I think that I have a problem with the redirection of .html files

The upload goes well, all files are created, but when I post the .html link on discord nothing happens.

However, if I open this link on a browser, it redirects me to SERVE_DOMAIN/SERVE_DOMAIN/video/test.mp4 instead of SERVE_DOMAIN/video/test.mp4

SERVE_DOMAIN/video/test.mp4 is playing fine on browser, so I suppose that its just a problem from the redirection in the .html

Here is what a generated .html with embed.example.com looks like :


    <!DOCTYPE html>
    <html>
    <!-- Generated at 2023-04-05 19:58:09 -->
    <head>
        <meta property="og:type" content="video.other">
        <meta property="twitter:player" content="i.example.com/video/test.mp4">
        <meta property="og:video:type" content="text/html">
        <meta property="og:video:width" content="1920">
        <meta property="og:video:height" content="1080">
        <meta name="twitter:image" content="i.example.com/test.mp4.jpg">
        <meta http-equiv="refresh" content="0;url=i.example.com/video/test.mp4">
    </head>
    </html>
    

Do you have an idea about what cause this issue, and how I can fix it ?

Thanks in advance

Fix code scanning alert - URL redirection from remote source

Tracking issue for:

Directly incorporating user input into a URL redirect request without validating the input can facilitate phishing attacks. In these attacks, unsuspecting users can be redirected to a malicious site that looks very similar to the real site they intend to visit, but which is controlled by the attacker.

Recommendation

To guard against untrusted URL redirection, it is advisable to avoid putting user input directly into a redirect URL. Instead, maintain a list of authorized redirects on the server; then choose from that list based on the user input provided.
Example

The following example shows an HTTP request parameter being used directly in a URL redirect without validating the input, which facilitates phishing attacks:

from flask import Flask, request, redirect

app = Flask(__name__)

@app.route('/')
def hello():
    target = request.args.get('target', '')
    return redirect(target, code=302)

One way to remedy the problem is to validate the user input against a known fixed string before doing the redirection:

from flask import Flask, request, redirect

VALID_REDIRECT = "http://cwe.mitre.org/data/definitions/601.html"

app = Flask(__name__)

@app.route('/')
def hello():
    target = request.args.get('target', '')
    if target == VALID_REDIRECT:
        return redirect(target, code=302)
    else:
        ... # Error

References

OWASP: XSS Unvalidated Redirects and Forwards Cheat Sheet.
Common Weakness Enumeration: CWE-601.

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.