Ankündigung

Einklappen
Keine Ankündigung bisher.

HTMLPurifier richtig konfigurieren (xss etc.)

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • HTMLPurifier richtig konfigurieren (xss etc.)

    Hallo,

    ich bin erst kürzlich auf den HTMLPurifier gestoßen und habe auch alternativen kennengelernt aber ich denke erst mal versuche ich es damit!
    Obwohl sich es selber als easy und quit beschreibt, finde ich den Einstieg so ganz und garnicht easy.

    Es ist installiert und "configuriert" bzw. bereits im Validierungsprozess eines Formulares eingebaut.
    Von einem HTML-reiniger, erwarte ich eigentlich auch das entsprechende XSS Versuche herausgefiltert werden.
    Man kann zwar sehr schön festlegen welche Tags und mit welchen Attributen zulässig sind, aber dessen Inhalte scheinen nicht wirklich überprüft zu werden!?!?

    Mit diesem Cheat Sheet sieht man sehr schön wie XSS auch in <style> -Elementen eingebunden werden kann und es wird alles nicht heraus gefiltert, kann HTMLPurifier das nicht, brauch ich da jetzt tatsächlich noch einen anderen Filter?

    Ich habe extra bereits durch eigene Vorarbeit gesorgt das der Inhalt der an HTMLPurifier übergeben wird leser lich ist (alle Zeichen decoded).

    MfG: Paykoman
    PS: hoffe mir kann da wer weiterhelfen

  • #2
    Zeig mal wie du den einsetzt.
    Hast du auch ein Beispiel in welchem Fall nicht das passiert was du erwarten würdest?

    [COLOR=#A9A9A9]Relax, you're doing fine.[/COLOR]
    [URL="http://php.net/"]RTFM[/URL] | [URL="http://php-de.github.io/"]php.de Wissenssammlung[/URL] | [URL="http://use-the-index-luke.com/de"]Datenbankindizes[/URL] | [URL="https://www.php.de/forum/webentwicklung/datenbanken/111631-bild-aus-datenbank-auslesen?p=1209079#post1209079"]Dateien in der DB?[/URL]

    Kommentar


    • #3
      Hi, danke für die fixe Antwort. Ich würde da gerne später darauf zurück kommen, habe gesehen im großen und ganzen filtert es alles raus.
      1-2 Sachen sind mir aber aufgefallen und den ein oder anderen Test würde ich gern vorher noch machen.

      Dazu müsste ich aber erst die Konfiguration abschließen.

      1) CSS: da es sich um ein iFrame mit alleinigem Userinhalt handelt (.html-Datei), sollen eigentlich so ziemlich alle normalen CSS-Befehle möglich sein. Leider werden Befehle wir 'box-shadow' heraus gefiltert.
      2) HTML: habe ich soweit eigentlich keine Probleme.

      Aber für beides wäre es toll, auf die bestehende Default-Config aufsetzten zu können, also die bereits existierenden Regel beibehalten und lediglich erweitern, geht das?
      Finde es etwas Umständlich das diese immer überschrieben werden. In meinem CSS-Fall wäre auch ein * für alle Propertys sinnvoll, der Purifier läuft ja so oder so vorher durch und filter Schadcode heraus.

      PHP-Code:
      $desc $form->retVal('desc''', ['strip_tags'=> false'url'=>false'htmlspecialchars'=>false], 'post');

      // HTML purifier
      require_once root.'/fw/plugins/HTMLPurifier/HTMLPurifier.auto.php';
      require_once 
      root.'/fw/plugins/csstidy/class.csstidy.php';

      // base config of purifier
      $config = \HTMLPurifier_Config::createDefault();
      $config->set('Cache.DefinitionImpl'null); // it disabled the purifier cache
      // $config->set('Cache.SerializerPath', root.'cache/HTMLPurifier'); // it set cache folder of purifier
      $config->set('URI.DefaultScheme''https');
      $config->set('URI.AllowedSchemes', ['https' => true]);
      // css
      $config->set('Filter.ExtractStyleBlocks'true);
      $config->set('CSS.AllowImportant'true);
      $config->set('CSS.AllowTricky'true);
      $config->set('CSS.Trusted'true);
      // $config->set('CSS.Proprietary', true);
      // $config->set('CSS.AllowedProperties', ['margin' => true, 'padding' => true]);
      // html
      $config->set('HTML.Trusted'true);
      // $config->set('URI.AllowedSchemes', ['http' => true, 'https' => false, 'mailto' => false, 'ftp' => false, 'nntp' => false, 'news' => false, 'tel' => false]);
      $config->set('HTML.SafeIframe'true);
      $config->set('HTML.Allowed''script,div');

      // run the purifier
      $purifier = new HTMLPurifier($config);
      $desc $purifier->purify($desc);

      // handle <style blocks
      $style '<style>';
      foreach( 
      $purifier->context->get('StyleBlocks') as $block => $css ){ $style .= $css."\n\n"; }
      $style .= '</style>';

      // Create new file
      $f fopenroot.MEDIA_FOLDER.'/auc_desc/test.html' 'wb');
      $content mb_convert_encoding($style.$desc'UTF-8'); // make sure that content is UTF-8 format!
      fwrite($f$content ); // Write to file
      fclose($f); 
      Ansonsten wären es hilfreich zuwissen in welchen Dateien die default withlist enthalten sind dann konnte man dort ggf. copy & paste machen und erweitern....

      MfG: Paykoman

      Kommentar


      • #4
        Zitat von Paykoman Beitrag anzeigen
        Ansonsten wären es hilfreich zuwissen in welchen Dateien die default withlist enthalten sind dann konnte man dort ggf. copy & paste machen und erweitern....
        Und selber nachschauen wäre da nicht in Frage gekommen?

        https://github.com/ezyang/htmlpurifi...ema/schema.ser

        Kommentar


        • #5
          Dann zeig mir doch mal bitte wo in deiner genannten Datei die HTML/CSS withlist steht (nicht der Speicherort die LISTE um darauf aufbauen zu können)? Sprich die jeweiligen Tags und deren erlaubten Attribute...
          In php habe ich die default schemen etc. auch schon alle gefunden aber eben nicht besagte Listen, es gibt nun auch nicht gerade wenig Dateien, deshalb nutze ich ja dieses Forum...

          Kommentar


          • #6
            Mach die Augen auf. Ich seh das in der verlinkten Datei.

            Kommentar


            • #7
              Also ich sehe da nicht ein html Tag...
              Code:
               
               __PHP_Incomplete_Class Object (     [__PHP_Incomplete_Class_Name] => HTMLPurifier_ConfigSchema     [defaults] => Array         (             [Attr.AllowedClasses] =>              [Attr.AllowedFrameTargets] => Array                 (                 )              [Attr.AllowedRel] => Array                 (                 )              [Attr.AllowedRev] => Array                 (                 )              [Attr.ClassUseCDATA] =>              [Attr.DefaultImageAlt] =>              [Attr.DefaultInvalidImage] =>              [Attr.DefaultInvalidImageAlt] => Invalid image             [Attr.DefaultTextDir] => ltr             [Attr.EnableID] =>              [Attr.ForbiddenClasses] => Array                 (                 )              [Attr.ID.HTML5] =>              [Attr.IDBlacklist] => Array                 (                 )              [Attr.IDBlacklistRegexp] =>              [Attr.IDPrefix] =>              [Attr.IDPrefixLocal] =>              [AutoFormat.AutoParagraph] =>              [AutoFormat.Custom] => Array                 (                 )              [AutoFormat.DisplayLinkURI] =>              [AutoFormat.Linkify] =>              [AutoFormat.PurifierLinkify.DocURL] => #%s             [AutoFormat.PurifierLinkify] =>              [AutoFormat.RemoveEmpty.Predicate] => Array                 (                     [colgroup] => Array                         (                         )                      [th] => Array                         (                         )                      [td] => Array                         (                         )                      [iframe] => Array                         (                             [0] => src                         )                  )              [AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions] => Array                 (                     [td] => 1                     [th] => 1                 )              [AutoFormat.RemoveEmpty.RemoveNbsp] =>              [AutoFormat.RemoveEmpty] =>              [AutoFormat.RemoveSpansWithoutAttributes] =>              [CSS.AllowDuplicates] =>              [CSS.AllowImportant] =>              [CSS.AllowTricky] =>              [CSS.AllowedFonts] =>              [CSS.AllowedProperties] =>              [CSS.DefinitionRev] => 1             [CSS.ForbiddenProperties] => Array                 (                 )              [CSS.MaxImgLength] => 1200px             [CSS.Proprietary] =>              [CSS.Trusted] =>              [Cache.DefinitionImpl] => Serializer             [Cache.SerializerPath] =>              [Cache.SerializerPermissions] => 493             [Core.AggressivelyFixLt] => 1             [Core.AggressivelyRemoveScript] => 1             [Core.AllowHostnameUnderscore] =>              [Core.CollectErrors] =>              [Core.ColorKeywords] => Array                 (                     [maroon] => #800000                     [red] => #FF0000                     [orange] => #FFA500                     [yellow] => #FFFF00                     [olive] => #808000                     [purple] => #800080                     [fuchsia] => #FF00FF                     [white] => #FFFFFF                     [lime] => #00FF00                     [green] => #008000                     [navy] => #000080                     [blue] => #0000FF                     [aqua] => #00FFFF                     [teal] => #008080                     [black] => #000000                     [silver] => #C0C0C0                     [gray] => #808080                 )              [Core.ConvertDocumentToFragment] => 1             [Core.DirectLexLineNumberSyncInterval] => 0             [Core.DisableExcludes] =>              [Core.EnableIDNA] =>              [Core.Encoding] => utf-8             [Core.EscapeInvalidChildren] =>              [Core.EscapeInvalidTags] =>              [Core.EscapeNonASCIICharacters] =>              [Core.HiddenElements] => Array                 (                     [script] => 1                     [style] => 1                 )              [Core.Language] => en             [Core.LegacyEntityDecoder] =>              [Core.LexerImpl] =>              [Core.MaintainLineNumbers] =>              [Core.NormalizeNewlines] => 1             [Core.RemoveInvalidImg] => 1             [Core.RemoveProcessingInstructions] =>              [Core.RemoveScriptContents] =>              [Filter.Custom] => Array                 (                 )              [Filter.ExtractStyleBlocks.Escaping] => 1             [Filter.ExtractStyleBlocks.Scope] =>              [Filter.ExtractStyleBlocks.TidyImpl] =>              [Filter.ExtractStyleBlocks] =>              [Filter.YouTube] =>              [HTML.Allowed] =>              [HTML.AllowedAttributes] =>              [HTML.AllowedComments] => Array                 (                 )              [HTML.AllowedCommentsRegexp] =>              [HTML.AllowedElements] =>              [HTML.AllowedModules] =>              [HTML.Attr.Name.UseCDATA] =>              [HTML.BlockWrapper] => p             [HTML.CoreModules] => Array                 (                     [Structure] => 1                     [Text] => 1                     [Hypertext] => 1[List] => 1                     [NonXMLCommonAttributes] => 1                     [XMLCommonAttributes] => 1                     [CommonAttributes] => 1                 )              [HTML.CustomDoctype] =>              [HTML.DefinitionID] =>              [HTML.DefinitionRev] => 1             [HTML.Doctype] =>              [HTML.FlashAllowFullScreen] =>              [HTML.ForbiddenAttributes] => Array                 (                 )              [HTML.ForbiddenElements] => Array                 (                 )              [HTML.MaxImgLength] => 1200             [HTML.Nofollow] =>              [HTML.Parent] => div             [HTML.Proprietary] =>              [HTML.SafeEmbed] =>              [HTML.SafeIframe] =>              [HTML.SafeObject] =>              [HTML.SafeScripting] => Array                 (                 )              [HTML.Strict] =>              [HTML.TargetBlank] =>              [HTML.TargetNoopener] => 1             [HTML.TargetNoreferrer] => 1             [HTML.TidyAdd] => Array                 (                 )              [HTML.TidyLevel] => medium             [HTML.TidyRemove] => Array                 (                 )              [HTML.Trusted] =>              [HTML.XHTML] => 1             [Output.CommentScriptContents] => 1             [Output.FixInnerHTML] => 1             [Output.FlashCompat] =>              [Output.Newline] =>              [Output.SortAttr] =>              [Output.TidyFormat] =>              [Test.ForceNoIconv] =>              [URI.AllowedSchemes] => Array                 (                     [http] => 1                     [https] => 1                     [mailto] => 1                     [ftp] => 1                     [nntp] => 1                     [news] => 1                     [tel] => 1                 )              [URI.Base] =>              [URI.DefaultScheme] => http             [URI.DefinitionID] =>              [URI.DefinitionRev] => 1             [URI.Disable] =>              [URI.DisableExternal] =>              [URI.DisableExternalResources] =>              [URI.DisableResources] =>              [URI.Host] =>              [URI.HostBlacklist] => Array                 (                 )              [URI.MakeAbsolute] =>              [URI.Munge] =>              [URI.MungeResources] =>              [URI.MungeSecretKey] =>              [URI.OverrideAllowedSchemes] => 1             [URI.SafeIframeRegexp] =>          )      [defaultPlist] => __PHP_Incomplete_Class Object         (             [__PHP_Incomplete_Class_Name] => HTMLPurifier_PropertyList             [ * data] => Array                 (                     [Attr.AllowedClasses] =>                      [Attr.AllowedFrameTargets] => Array                         (                         )                      [Attr.AllowedRel] => Array                         (                         )                      [Attr.AllowedRev] => Array                         (                         )                      [Attr.ClassUseCDATA] =>                      [Attr.DefaultImageAlt] =>                      [Attr.DefaultInvalidImage] =>                      [Attr.DefaultInvalidImageAlt] => Invalid image                     [Attr.DefaultTextDir] => ltr                     [Attr.EnableID] =>                      [Attr.ForbiddenClasses] => Array                         (                         )                      [Attr.ID.HTML5] =>                      [Attr.IDBlacklist] => Array                         (                         )                      [Attr.IDBlacklistRegexp] =>                      [Attr.IDPrefix] =>                      [Attr.IDPrefixLocal] =>                      [AutoFormat.AutoParagraph] =>                      [AutoFormat.Custom] => Array                         (                         )                      [AutoFormat.DisplayLinkURI] =>                      [AutoFormat.Linkify] =>                      [AutoFormat.PurifierLinkify.DocURL] => #%s                     [AutoFormat.PurifierLinkify] =>                      [AutoFormat.RemoveEmpty.Predicate] => Array                         (                             [colgroup] => Array                                 (                                 )                              [th] => Array                                 (                                 )                              [td] => Array                                 (                                 )                              [iframe] => Array                                 (                                     [0] => src                                 )                          )                      [AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions] => Array                         (                             [td] => 1                             [th] => 1                         )                      [AutoFormat.RemoveEmpty.RemoveNbsp] =>                      [AutoFormat.RemoveEmpty] =>                      [AutoFormat.RemoveSpansWithoutAttributes] =>                      [CSS.AllowDuplicates] =>                      [CSS.AllowImportant] =>                      [CSS.AllowTricky] =>                      [CSS.AllowedFonts] =>                      [CSS.AllowedProperties] =>                      [CSS.DefinitionRev] => 1                     [CSS.ForbiddenProperties] => Array                         (                         )                      [CSS.MaxImgLength] => 1200px                     [CSS.Proprietary] =>                      [CSS.Trusted] =>                      [Cache.DefinitionImpl] => Serializer                     [Cache.SerializerPath] =>                      [Cache.SerializerPermissions] => 493                     [Core.AggressivelyFixLt] => 1                     [Core.AggressivelyRemoveScript] => 1                     [Core.AllowHostnameUnderscore] =>                      [Core.CollectErrors] =>                      [Core.ColorKeywords] => Array                         (                             [maroon] => #800000                             [red] => #FF0000                             [orange] => #FFA500                             [yellow] => #FFFF00                             [olive] => #808000                             [purple] => #800080                             [fuchsia] => #FF00FF                             [white] => #FFFFFF                             [lime] => #00FF00                             [green] => #008000                             [navy] => #000080                             [blue] => #0000FF                             [aqua] => #00FFFF                             [teal] => #008080                             [black] => #000000                             [silver] => #C0C0C0                             [gray] => #808080                         )                      [Core.ConvertDocumentToFragment] => 1                     [Core.DirectLexLineNumberSyncInterval] => 0                     [Core.DisableExcludes] =>                      [Core.EnableIDNA] =>                      [Core.Encoding] => utf-8                     [Core.EscapeInvalidChildren] =>                      [Core.EscapeInvalidTags] =>                      [Core.EscapeNonASCIICharacters] =>                      [Core.HiddenElements] => Array                         (                             [script] => 1                             [style] => 1                         )                      [Core.Language] => en                     [Core.LegacyEntityDecoder] =>                      [Core.LexerImpl] =>                      [Core.MaintainLineNumbers] =>                      [Core.NormalizeNewlines] => 1                     [Core.RemoveInvalidImg] => 1                     [Core.RemoveProcessingInstructions] =>                      [Core.RemoveScriptContents] =>                      [Filter.Custom] => Array                         (                         )                      [Filter.ExtractStyleBlocks.Escaping] => 1                     [Filter.ExtractStyleBlocks.Scope] =>                      [Filter.ExtractStyleBlocks.TidyImpl] =>                      [Filter.ExtractStyleBlocks] =>                      [Filter.YouTube] =>                      [HTML.Allowed] =>                      [HTML.AllowedAttributes] =>                      [HTML.AllowedComments] => Array                         (                         )                      [HTML.AllowedCommentsRegexp] =>                      [HTML.AllowedElements] =>                      [HTML.AllowedModules] =>                      [HTML.Attr.Name.UseCDATA] =>                      [HTML.BlockWrapper] => p                     [HTML.CoreModules] => Array                         (                             [Structure] => 1                             [Text] => 1                             [Hypertext] => 1[List] => 1                             [NonXMLCommonAttributes] => 1                             [XMLCommonAttributes] => 1                             [CommonAttributes] => 1                         )                      [HTML.CustomDoctype] =>                      [HTML.DefinitionID] =>                      [HTML.DefinitionRev] => 1                     [HTML.Doctype] =>                      [HTML.FlashAllowFullScreen] =>                      [HTML.ForbiddenAttributes] => Array                         (                         )                      [HTML.ForbiddenElements] => Array                         (                         )                      [HTML.MaxImgLength] => 1200                     [HTML.Nofollow] =>                      [HTML.Parent] => div                     [HTML.Proprietary] =>                      [HTML.SafeEmbed] =>                      [HTML.SafeIframe] =>                      [HTML.SafeObject] =>                      [HTML.SafeScripting] => Array                         (                         )                      [HTML.Strict] =>                      [HTML.TargetBlank] =>                      [HTML.TargetNoopener] => 1                     [HTML.TargetNoreferrer] => 1                     [HTML.TidyAdd] => Array                         (                         )                      [HTML.TidyLevel] => medium                     [HTML.TidyRemove] => Array                         (                         )                      [HTML.Trusted] =>                      [HTML.XHTML] => 1                     [Output.CommentScriptContents] => 1                     [Output.FixInnerHTML] => 1                     [Output.FlashCompat] =>                      [Output.Newline] =>                      [Output.SortAttr] =>                      [Output.TidyFormat] =>                      [Test.ForceNoIconv] =>                      [URI.AllowedSchemes] => Array                         (                             [http] => 1                             [https] => 1                             [mailto] => 1                             [ftp] => 1                             [nntp] => 1                             [news] => 1                             [tel] => 1                         )                      [URI.Base] =>                      [URI.DefaultScheme] => http                     [URI.DefinitionID] =>                      [URI.DefinitionRev] => 1                     [URI.Disable] =>                      [URI.DisableExternal] =>                      [URI.DisableExternalResources] =>                      [URI.DisableResources] =>                      [URI.Host] =>                      [URI.HostBlacklist] => Array                         (                         )                      [URI.MakeAbsolute] =>                      [URI.Munge] =>                      [URI.MungeResources] =>                      [URI.MungeSecretKey] =>                      [URI.OverrideAllowedSchemes] => 1                     [URI.SafeIframeRegexp] =>                  )              [ * parent] =>              [ * cache] =>          )      [info] => Array         (             [Attr.AllowedClasses] => -8             [Attr.AllowedFrameTargets] => 8             [Attr.AllowedRel] => 8             [Attr.AllowedRev] => 8             [Attr.ClassUseCDATA] => -7             [Attr.DefaultImageAlt] => -1             [Attr.DefaultInvalidImage] => 1             [Attr.DefaultInvalidImageAlt] => 1             [Attr.DefaultTextDir] => stdClass Object                 (                     [type] => 1                     [allowed] => Array                         (                             [ltr] => 1                             [rtl] => 1                         )                  )              [Attr.EnableID] => 7             [HTML.EnableAttrID] => stdClass Object                 (                     [key] => Attr.EnableID                     [isAlias] => 1                 )              [Attr.ForbiddenClasses] => 8             [Attr.ID.HTML5] => -7             [Attr.IDBlacklist] => 9             [Attr.IDBlacklistRegexp] => -1             [Attr.IDPrefix] => 1             [Attr.IDPrefixLocal] => 1             [AutoFormat.AutoParagraph] => 7             [AutoFormat.Custom] => 9             [AutoFormat.DisplayLinkURI] => 7             [AutoFormat.Linkify] => 7             [AutoFormat.PurifierLinkify.DocURL] => 1             [AutoFormatParam.PurifierLinkifyDocURL] => stdClass Object                 (                     [key] => AutoFormat.PurifierLinkify.DocURL                     [isAlias] => 1                 )              [AutoFormat.PurifierLinkify] => 7             [AutoFormat.RemoveEmpty.Predicate] => 10             [AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions] => 8             [AutoFormat.RemoveEmpty.RemoveNbsp] => 7             [AutoFormat.RemoveEmpty] => 7             [AutoFormat.RemoveSpansWithoutAttributes] => 7             [CSS.AllowDuplicates] => 7             [CSS.AllowImportant] => 7             [CSS.AllowTricky] => 7             [CSS.AllowedFonts] => -8             [CSS.AllowedProperties] => -8             [CSS.DefinitionRev] => 5             [CSS.ForbiddenProperties] => 8             [CSS.MaxImgLength] => -1             [CSS.Proprietary] => 7             [CSS.Trusted] => 7             [Cache.DefinitionImpl] => -1             [Core.DefinitionCache] => stdClass Object                 (                     [key] => Cache.DefinitionImpl                     [isAlias] => 1                 )              [Cache.SerializerPath] => -1             [Cache.SerializerPermissions] => -5             [Core.AggressivelyFixLt] => 7             [Core.AggressivelyRemoveScript] => 7             [Core.AllowHostnameUnderscore] => 7             [Core.CollectErrors] => 7             [Core.ColorKeywords] => 10             [Core.ConvertDocumentToFragment] => 7             [Core.AcceptFullDocuments] => stdClass Object                 (                     [key] => Core.ConvertDocumentToFragment                     [isAlias] => 1                 )              [Core.DirectLexLineNumberSyncInterval] => 5             [Core.DisableExcludes] => 7             [Core.EnableIDNA] => 7             [Core.Encoding] => 2             [Core.EscapeInvalidChildren] => 7             [Core.EscapeInvalidTags] => 7             [Core.EscapeNonASCIICharacters] => 7             [Core.HiddenElements] => 8             [Core.Language] => 1             [Core.LegacyEntityDecoder] => 7             [Core.LexerImpl] => -11             [Core.MaintainLineNumbers] => -7             [Core.NormalizeNewlines] => 7             [Core.RemoveInvalidImg] => 7             [Core.RemoveProcessingInstructions] => 7             [Core.RemoveScriptContents] => -7             [Filter.Custom] => 9             [Filter.ExtractStyleBlocks.Escaping] => 7             [Filter.ExtractStyleBlocksEscaping] => stdClass Object                 (                     [key] => Filter.ExtractStyleBlocks.Escaping                     [isAlias] => 1                 )              [FilterParam.ExtractStyleBlocksEscaping] => stdClass Object                 (                     [key] => Filter.ExtractStyleBlocks.Escaping                     [isAlias] => 1                 )              [Filter.ExtractStyleBlocks.Scope] => -1             [Filter.ExtractStyleBlocksScope] => stdClass Object                 (                     [key] => Filter.ExtractStyleBlocks.Scope                     [isAlias] => 1                 )              [FilterParam.ExtractStyleBlocksScope] => stdClass Object                 (                     [key] => Filter.ExtractStyleBlocks.Scope                     [isAlias] => 1                 )              [Filter.ExtractStyleBlocks.TidyImpl] => -11             [FilterParam.ExtractStyleBlocksTidyImpl] => stdClass Object                 (                     [key] => Filter.ExtractStyleBlocks.TidyImpl                     [isAlias] => 1                 )              [Filter.ExtractStyleBlocks] => 7             [Filter.YouTube] => 7             [HTML.Allowed] => -4             [HTML.AllowedAttributes] => -8             [HTML.AllowedComments] => 8             [HTML.AllowedCommentsRegexp] => -1             [HTML.AllowedElements] => -8             [HTML.AllowedModules] => -8             [HTML.Attr.Name.UseCDATA] => 7             [HTML.BlockWrapper] => 1             [HTML.CoreModules] => 8             [HTML.CustomDoctype] => -1             [HTML.DefinitionID] => -1             [HTML.DefinitionRev] => 5             [HTML.Doctype] => stdClass Object                 (                     [type] => 1                     [allow_null] => 1                     [allowed] => Array                         (                             [HTML 4.01 Transitional] => 1                             [HTML 4.01 Strict] => 1                             [XHTML 1.0 Transitional] => 1                             [XHTML 1.0 Strict] => 1                             [XHTML 1.1] => 1                         )                  )              [HTML.FlashAllowFullScreen] => 7             [HTML.ForbiddenAttributes] => 8             [HTML.ForbiddenElements] => 8             [HTML.MaxImgLength] => -5             [HTML.Nofollow] => 7             [HTML.Parent] => 1             [HTML.Proprietary] => 7             [HTML.SafeEmbed] => 7             [HTML.SafeIframe] => 7             [HTML.SafeObject] => 7             [HTML.SafeScripting] => 8             [HTML.Strict] => 7             [HTML.TargetBlank] => 7             [HTML.TargetNoopener] => 7             [HTML.TargetNoreferrer] => 7             [HTML.TidyAdd] => 8             [HTML.TidyLevel] => stdClass Object                 (                     [type] => 1                     [allowed] => Array                         (                             [none] => 1                             [light] => 1                             [medium] => 1                             [heavy] => 1                         )                  )              [HTML.TidyRemove] => 8             [HTML.Trusted] => 7             [HTML.XHTML] => 7             [Core.XHTML] => stdClass Object                 (                     [key] => HTML.XHTML                     [isAlias] => 1                 )              [Output.CommentScriptContents] => 7             [Core.CommentScriptContents] => stdClass Object                 (                     [key] => Output.CommentScriptContents                     [isAlias] => 1                 )              [Output.FixInnerHTML] => 7             [Output.FlashCompat] => 7             [Output.Newline] => -1             [Output.SortAttr] => 7             [Output.TidyFormat] => 7             [Core.TidyFormat] => stdClass Object                 (                     [key] => Output.TidyFormat                     [isAlias] => 1                 )              [Test.ForceNoIconv] => 7             [URI.AllowedSchemes] => 8             [URI.Base] => -1             [URI.DefaultScheme] => -1             [URI.DefinitionID] => -1             [URI.DefinitionRev] => 5             [URI.Disable] => 7             [Attr.DisableURI] => stdClass Object                 (                     [key] => URI.Disable                     [isAlias] => 1                 )              [URI.DisableExternal] => 7             [URI.DisableExternalResources] => 7             [URI.DisableResources] => 7             [URI.Host] => -1             [URI.HostBlacklist] => 9             [URI.MakeAbsolute] => 7             [URI.Munge] => -1             [URI.MungeResources] => 7             [URI.MungeSecretKey] => -1             [URI.OverrideAllowedSchemes] => 7             [URI.SafeIframeRegexp] => -1         )  )
              Also bei mir sind die HTML.Allowed arrays leer, und selbst wenn, gesucht war eine Textform die man wieder verwenden kann, also entsprechend der Dokumentation: "element1[attr1|attr2],element2....", hier hat das System bereits eine Whitelist, wo befindet sich diese, damit man sie kopieren und darauf aufbauen kann? Denn wenn man anfängt eine eigene Liste zu erstellen wird die default stehts überschrieben.

              Kommentar


              • #8
                Zitat von Paykoman Beitrag anzeigen
                Also bei mir sind die HTML.Allowed arrays leer, und selbst wenn, gesucht war eine Textform die man wieder verwenden kann, also entsprechend der Dokumentation: "element1[attr1|attr2],element2....", hier hat das System bereits eine Whitelist, wo befindet sich diese, damit man sie kopieren und darauf aufbauen kann? Denn wenn man anfängt eine eigene Liste zu erstellen wird die default stehts überschrieben.
                Was willst du überhaupt? Wenn du genau weißt, was du zulassen willst, dann erstelle eine eigene Whitelist. Wenn du nur spezielle Elemente nicht erlauben willst, verwende eine Blacklist.

                Nach einigen Threads habe ich den Eindruck, dass du dir vieles unnötig kompliziert machst und unnötig über 5 Ecken arbeitest.

                Kommentar


                • #9
                  Nun so kompliziert war diese Frage hier nicht. Bisher hatte ich noch anderes zu tun aber in Kürze werde ich an der Konfiguration weiter arbeiten.
                  Es gibt einen ganzen Haufen an Elemente und Attribute die ich erlauben möchte, da eine Whitelist sicherer ist als eine Blacklist, wollte ich mir lediglich ein paar Stunden ersparen, denn irgendwo in dem HTMLPurifier muss ja genau solch eine Liste existieren (in string-form = "element1[attr1|attr2],element2....") die eben in der Defaultconfig geladen wird.

                  Ich möchte doch nur diesen String haben um ihn erweitern zu können und mir die Stunden erspare selber diesen String zusammen zustellen.
                  Das ist doch nun wirklich nicht schwer zu verstehen oder nachzuvollziehen.

                  Kommentar


                  • #10
                    Nun so kompliziert war diese Frage hier nicht.
                    Zielsicher das richtige Ungterforum gefunden.
                    denn irgendwo in dem HTMLPurifier muss ja genau solch eine Liste existieren (in string-form = "element1[attr1|attr2],element2....") die eben in der Defaultconfig geladen wird.
                    könnte man ja suchen.
                    Ich würde mal das anschauen...
                    https://github.com/ezyang/htmlpurifi...dule/Forms.php

                    Kommentar


                    • #11
                      Mich wunder echt eure Überheblichkeit, denn bisher kamen nur dumme Sprüche und Verweise auf alles mögliche nur nicht dem gesuchten...
                      Zielsicher das richtige Ungterforum gefunden.
                      Das Ursprungsthema war ein anderes, auf dieses wollte ich ja nach dem man mir kurz geholfen hätte eben diese scheiß Liste zu finden wieder darauf zurück kommen, da aber ja lieber Vorwurf gemacht werden man würde selber nicht danach suchen und dann eben einfach irgend etwas Postet, hat es das Thema ja wieder ziemlich zerrissen, wie leider so oft.

                      Fakt ist, die Dokumentation gibt vor wie die Witheliste zu erstellen ist (String-form), fakt ist, das Skript erstellt standardmäßig eine solche Liste, ich vermute daher ja auch nur das eben genau solch ein String für die default-Liste genutzt wird, kann ja auch sein das die default-Liste anders generiert wird, ich weiß es nicht.

                      Da hier erfahrene User sind und sicher selber schon mal derartiges gebraucht haben hoffte ich das a) entweder Jemand weiß wo solch eine Liste zu finden ist oder b) eben weiß wo HTMLPurifier seine eigene Liste im quellcode stehen hat.

                      Scheint aber zuviel verlangt zu sein daher werde ich gleich anfangen selber eine zu erstellen.
                      Anschließend werde ich zwecks der Konfiguration ein neues Thema machen da ich schon noch die ein oder andere Frage hätte, hier sind also keine weiteren Antworten nötig.

                      Kommentar


                      • #12
                        Es gibt einen ganzen Haufen an Elemente und Attribute die ich erlauben möchte, da eine Whitelist sicherer ist als eine Blacklist
                        strip_tags() reicht nicht?
                        The string "()()" is not palindrom but the String "())(" is.

                        Debugging: Finde DEINE Fehler selbst! | Gegen Probleme beim E-Mail-Versand | Sicheres Passwort-Hashing | Includes niemals ohne __DIR__
                        PHP.de Wissenssammlung | Kein Support per PN

                        Kommentar


                        • #13
                          Zitat von hausl Beitrag anzeigen

                          strip_tags() reicht nicht?
                          Leider nicht, da es sich um eine HTML-Beschreibung handelt die vom User gesendet wird.
                          Die grundlegenden Elemente einschließlich deren Attribute und zulässige Child-Elemente sind in der Standardkonfig bereits drin, deshalb wollte ich diese nutzten und fehlende Sachen ergänzen, nun habe ich eine eigene neue Liste angefangen (dauert aber noch ein Weilchen bis die soweit ist wie die default ist).

                          Kommentar


                          • #14
                            Nur sicherheitshalber.. strip_tags() hat einen zweiten Parameter.
                            allowable_tags Sie können den optionalen zweiten Parameter verwenden, um die Tags anzugeben, die nicht entfernt werden sollen.
                            The string "()()" is not palindrom but the String "())(" is.

                            Debugging: Finde DEINE Fehler selbst! | Gegen Probleme beim E-Mail-Versand | Sicheres Passwort-Hashing | Includes niemals ohne __DIR__
                            PHP.de Wissenssammlung | Kein Support per PN

                            Kommentar


                            • #15
                              Hehe, ja den verwende ich standardmäßig auch, hast ja gestern bissl was von meinem System gelesen, da gehört diese Funktion zur Standardmäßigen Validierung jeden Inputs.
                              Auch für das Eingabefeld der HTML-Beschreibung nutze ich es um schon mal nur zugelassene Elemente sicher zustellen. Mit dem HTMLPurifier kann man die Sicherheit noch mal deutlich erhöhen, wenn z.B. der script-Tag kein src-Attribut mehr setzten kann und überhaupt filtert es eben schon mal schön XSS-Sachen heraus.

                              Problematisch ist eben wenn man das ein oder andere Element mehr zulassen möchte als es die defaultconfig vorher sieht, dann kann man leider nicht hergehen und dieses Element einfach hinzufügen, nein man darf eine gesamte Liste anlegen. Selbiges Problem bei CSS, leider.

                              Aber wie gesagt, jetzt habe ich eh angefangen die Liste selber zu erstellen.

                              Kommentar

                              Lädt...
                              X