{"id":1078,"date":"2019-05-12T18:51:59","date_gmt":"2019-05-12T18:51:59","guid":{"rendered":"http:\/\/reichartonline.de\/?page_id=1078"},"modified":"2020-05-10T08:56:46","modified_gmt":"2020-05-10T08:56:46","slug":"method-whitelisting","status":"publish","type":"page","link":"https:\/\/reichartonline.de\/?page_id=1078","title":{"rendered":"Method whitelisting"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Motivation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Whitelisting callers introduces a level of security in cases where<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>the class holding the calling method has a (too) different purpose than to be derived from the class holding the (protected) method to be called in order to inherit the same<\/li><li>methods contained in different classes are to be permitted to call a specific method of another class (without inheriting the same)<\/li><li>the programming language used does not support protecting methods (restricting visibility) or does not support objects at all (but just functions)<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Benefits<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Method whitelists provide a mean to restrict calling public methods to defined (trusted) calling methods. This affects &#8220;inner security&#8221;, which refers to an accidental misuse of a public method by a developer as well as a potentially illegal call by malicious code injected by a threat agent.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Precondition<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The programming language used needs to support a mean to access the stack trace in order to evaluate a calling class and method.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Approach<\/h3>\n\n\n\n<ol class=\"wp-block-list\"><li>Embed the whitelist checker (method) into a base class inherited by all classes that are to use it<\/li><li>The whitelist checker takes a string array or list of the names of the methods permitted to call a target method<\/li><li>On being called, the whitelist checker gets the calling method or function from the stack trace and compares it to the entries white-listed<\/li><li>If the calling method or function is white-listed, execution is continued, else an exception is thrown or a fatal error is raised<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Example<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The following example (using the PHLEX application framework) demonstrates an exception on a call of a method by another (unpermitted\/ unauthorized) method (the file name and line number have been anonymized). Depending on the debug level, hints regarding authorized methods may be output.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/reichartonline.de\/content\/wp-content\/uploads\/2019\/05\/20190512_PHLEX_method_whitelisting.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1009\" height=\"64\" src=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2019\/05\/20190512_PHLEX_method_whitelisting.png\" alt=\"Method whitelisting\" class=\"wp-image-1077\" srcset=\"https:\/\/reichartonline.de\/content\/wp-content\/uploads\/2019\/05\/20190512_PHLEX_method_whitelisting.png 1009w, https:\/\/reichartonline.de\/content\/wp-content\/uploads\/2019\/05\/20190512_PHLEX_method_whitelisting-300x19.png 300w, https:\/\/reichartonline.de\/content\/wp-content\/uploads\/2019\/05\/20190512_PHLEX_method_whitelisting-768x49.png 768w\" sizes=\"auto, (max-width: 1009px) 100vw, 1009px\" \/><\/a><figcaption>Whitelisting of calling methods<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Motivation Whitelisting callers introduces a level of security in cases where the class holding the calling method has a (too) different purpose than to be derived from the class holding the (protected) method to be called in order to inherit the same methods contained in different classes are to be permitted to call a specific [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":62,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"class_list":["post-1078","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/1078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reichartonline.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1078"}],"version-history":[{"count":6,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/1078\/revisions"}],"predecessor-version":[{"id":1139,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/1078\/revisions\/1139"}],"up":[{"embeddable":true,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/62"}],"wp:attachment":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}