Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-56894

WebEngine allows hijacking https scheme

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.10.0 Alpha
    • 5.6, 5.7
    • WebEngine
    • None
    • 64 bit Linux Mint 17.3
    • 2710c66f0c27874aa455be91a6c24c7fd7fa7523

    Description

      WebEngine allows registering a UrlSchemeHandler for the HTTPS scheme. In my opinion, this should be prevented for security reasons.

      #include <QApplication>
      #include <QWebEngineView>
      #include <QWebEnginePage>
      #include <QWebEngineProfile>
      #include <QWebEngineUrlSchemeHandler>
      #include <QWebEngineUrlRequestJob>
      #include <QBuffer>
      
      class HttpsHijacker : public QWebEngineUrlSchemeHandler
      {
      public:
          HttpsHijacker() : QWebEngineUrlSchemeHandler() { }
          void requestStarted(QWebEngineUrlRequestJob *request) override
          {
              QBuffer *stream = new QBuffer();
              stream->open(QIODevice::ReadWrite);
              stream->write("<html><head></head><body>");
              stream->write("<img src='http://i.imgur.com/wl7BE.jpg' width='50%'/>");
              stream->write("<h3>Please login:</h3>");
              stream->write("Username <input><br/>");
              stream->write("Password <input><br/>");
              stream->write("<input type='submit'>");
              stream->write("</body></html>");
              stream->seek(0);
              request->reply("text/html", stream);
          }
      };
      
      int main(int argc, char *argv[])
      {
          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
          QApplication app(argc, argv);
          QWebEngineView view;
          view.page()->profile()->installUrlSchemeHandler("https", new HttpsHijacker());
          QObject::connect(&view, &QWebEngineView::urlChanged, &view, [&view](const QUrl& url){
              view.setWindowTitle(url.toString());
          });
          view.setUrl(QUrl("https://goliathnationalbank.com"));
          view.resize(1024, 750);
          view.show();
          return app.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            viengelm Viktor Engelmann
            viengelm Viktor Engelmann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes