Skip to content

Commit 4be8bc4

Browse files
committed
Security related fixes to harder URL paths
1 parent 286b007 commit 4be8bc4

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
[assembly: CLSCompliant(false)]
2020
[assembly: ComVisible(false)]
2121
[assembly: AllowPartiallyTrustedCallers]
22-
[assembly: AssemblyVersion("3.1.3.8")]
22+
[assembly: AssemblyVersion("3.1.3.9")]
2323
[assembly: SecurityRules(SecurityRuleSet.Level1)]

BlogEngine/BlogEngine.Core/Web/HttpHandlers/Apml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public bool IsReusable
4242
/// </param>
4343
public void ProcessRequest(HttpContext context)
4444
{
45+
if (context.Request.FilePath.ToLower() != Utils.RelativeWebRoot + "apml.axd")
46+
throw new HttpException(404, "File not found");
47+
4548
context.Response.ContentType = "text/xml";
4649
WriteApmlDocument(context.Response.OutputStream);
4750
}

BlogEngine/BlogEngine.Core/Web/UrlRules.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,21 @@ public static void RewriteTag(HttpContext context, string url)
195195
/// <param name="url">The URL string.</param>
196196
public static void RewriteCalendar(HttpContext context, string url)
197197
{
198+
// prevent fake URLs
199+
// valid: "/calendar/"
200+
// valid: "/calendar/default.aspx"
201+
// invalid: "/fake-value/calendar/default.aspx"
202+
// invalid: "/calendar/fake-value/default.aspx"
203+
204+
url = url.ToLower();
205+
var validUrl = Utils.RelativeWebRoot.ToLower() + "calendar";
206+
207+
if (!url.StartsWith(validUrl))
208+
throw new HttpException(404, "File not found");
209+
210+
if(url.Contains("default.aspx") && !url.Contains("calendar/default.aspx"))
211+
throw new HttpException(404, "File not found");
212+
198213
context.RewritePath(string.Format("{0}default.aspx?calendar=show", Utils.ApplicationRelativeWebRoot), false);
199214
}
200215

0 commit comments

Comments
 (0)